While we were discussing lambda syntax..

Philippe Sigaud philippe.sigaud at gmail.com
Sat Jan 1 09:37:55 PST 2011


>> I just developed a n-args
>> version of UnaryFun/BinaryFun, which was one of the most useful little
>> helper I ever did in D.
>
> Great! I recall I tried to do that a couple of years ago, but hit a few
> bugs. Could you make NaryFun into a proposal for Phobos?

Sure. It uses a simple heuristics to automatically determine the
'string arity': it looks for lone letters (not surrounded by other
letters). In practice it works quite well and there is a optional
arity, if you need one.

The current code still uses templates instead of CTFE for this arity
determination. I'll change that and propose it.

One of my week-end plan was to do a curried version. That is
curriedFun!"a+b*c" would create not a 3-arg function template but
three unary templated funs inside one another. I find currying most
useful for mapping and filtering ranges...

Would that be of interest for someone?

Philippe


More information about the Digitalmars-d mailing list