A bit of curry?
I’m talking about Currying, “the technique of transforming a function that takes multiple arguments into a function that takes a single argument…”
With two recent additions to Prexonite (Script), it has become very easy to implement higher-order functions, including “curry” and “uncurry”.
With “additions” I’m referring to Closures as a virtual machine feature and Lambda Expressions as a Prexonite Script expansion. Something of the form (a1, a2, a3, … , an) => expr is an expression that is compiled into a separate function. Instead of a value, such a construct returns a closure, an enhanced reference to that anonymous function, that acts like a normal function reference. It get’s even better: As this so called lambda expression is defined inside another function, you can use local variables as if they were part of the expression. That’s also the reason why this closure-thingy is returned instead of a normal function reference: It carries information about additional local variables available to the lambda expression. More »