Marketing of D - article topic ideas?

Nick Sabalausky a at a.a
Tue Jun 8 11:13:15 PDT 2010


"Andrei Alexandrescu" <SeeWebsiteForEmail at erdani.org> wrote in message 
news:huld21$15sj$1 at digitalmars.com...
> On 06/07/2010 05:16 PM, Nick Sabalausky wrote:
>> "Nick Sabalausky"<a at a.a>  wrote in message
>> news:hujd9m$11of$1 at digitalmars.com...
>>> "Nick Sabalausky"<a at a.a>  wrote in message
>>> news:hujd6a$11e8$1 at 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?




More information about the Digitalmars-d mailing list