std.functional.curry isn't

bearophile bearophileHUGS at lycos.com
Thu Jun 24 17:37:25 PDT 2010


Graham Fawcett:
> If this were a real curry, you would write it like this:
> int fun(int a, int b) { return a + b; }
> assert(curry!(fun)(5)(6) == 11);

Right. Better to change the name.

Regarding std.functional, are the HOF adjoin(), compose() and pipe() useful? I don't think I'll use compose() or pipe(). If not enough people find them useful, then they can be removed.

There is something that instead I'd like added (that I am going to put as request in Bugzilla, maybe later today):

Apply functionality is quite useful, as shown by this small Python program that prints "1, 2":

def foo(x, y):
    print x, y
tuple1 = (1, 2)
foo(*tuple1)

That star syntax of Python is equivalent to this, that works still in Python 2.x:
apply(foo, tuple1)

The star syntax can't be used in D, but a good apply() function can be useful in D too. There the tuple is of course a std.typecons.Tuple.

Bye,
bearophile


More information about the Digitalmars-d mailing list