On Tue, Jun 8, 2010 at 14:28, Andrei Alexandrescu < seewebsiteforem...@erdani.org> wrote: > > This is kind of funny. This works because reduce is defined as follows: > > template reduce(alias fun) > { > alias Reduce!(fun).reduce reduce; > } > > I did that to work around some old compiler bugs that have been since > fixed. I'd initially intended to define reduce like this: > > Unqual!E reduce(alias fun, E, R)(E seed, R r) { ... } > > but that wouldn't have allowed Nick's alias, which is quite useful. So it > looks like we have a cool idiom.
Currying in general is always handy to have. The possibility to say alias map!fun funMapper; would be cool also. If possible, having this in Phobos would be quite nice. Bu then, I'm one of those persons that'd like to have alias take(3) takeThree; // will then work on any range. Instead of take(range, 3). If find the former to be much more generic. I liked it so much I defined a small template to invert and curry these (R,n) functions. Philippe