Curried Functions



On 2/18/08, Peter Danenberg <pcd at wikitex.org> wrote:

> Does it matter, by the way, whether you use the macro operator, ::=?
> It seems to work both ways.

Well, if it were written as a macro, the arguments would be quoted.
As a function:

curry(f, [args]) := buildq ([f, args], lambda([[x]], apply (f,
append(args, x))));
foo : 1234;
curry ("*", foo);
 => lambda([[x]], apply(*, append([1234], x)))

As a macro:
curry(f, [args]) ::= buildq ([f, args], lambda([[x]], apply (f,
append(args, x))));
foo : 1234;
curry ("*", foo);
 => lambda([[x]], apply(*, append([foo], x)))

Which one to choose depends on what you're aiming for ...

best

Robert Dodier