"Andrei Alexandrescu" <seewebsiteforem...@erdani.org> wrote in message news:huld21$15s...@digitalmars.com... > On 06/07/2010 05:16 PM, Nick Sabalausky wrote: >> "Nick Sabalausky"<a...@a.a> wrote in message >> news:hujd9m$11o...@digitalmars.com... >>> "Nick Sabalausky"<a...@a.a> wrote in message >>> news:hujd6a$11e...@digitalmars.com... >>>> >>>> Assuming, of course, a 'max' that works on a range, which would be easy >>>> enough to do. Probably something like: >>>> >>> >>> ElementType!T max(T range) // Corrected >>> >>>> { >>>> return reduce!ordinaryMax(range); >>>> // Or >>>> return reduce!"a>b?a:b"(range); >>>> } >>>> >>> >> >> Or: >> >> alias reduce!"a>b?a:b" max; >> >> God, I love D :) > > 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. >
Template currying ;) Maybe not as flexible as typical currying, but still. Curry...dang, now I'm hungry... Also, what's Unqual?