challenge #2: implement the varargs_reduce metafunction

janderson askme at me.com
Tue Jan 23 09:16:26 PST 2007


Andrei Alexandrescu (See Website for Email) wrote:
> My previous post defines max by availing itself of a metafunction called
> varargs_reduce. Your challenge is to define it. varargs_reduce takes an
> alias which it assumes is a function of two arguments, and it defines a
> vararg function that applies that alias repeatedly, similarly to the
> reduce primitive that is present in functional languages. Again, for
> background on functional reduce, see e.g.:
> 
> http://www.joelonsoftware.com/items/2006/08/01.html
> 
> Define varargs_reduce to deduce the result type properly, and to 
> generate code as efficient as possible.
> 
> 
> Andrei


While your at it.  What about a multi-threaded version?   ie Each 
function that is called is placed on one of 4 threads.

-Joel



More information about the Digitalmars-d mailing list