map/filter/reduce: use functions or delegates or both?

Daniel Keep daniel.keep.lists at gmail.com
Wed Mar 21 15:51:22 PDT 2007



Denton Cockburn wrote:
> oh yeah, map would need to be instantiated as well.
> 
> int[] b = reduce!(int, int)(plus, 0, map!(int, int)(square, a));

D has implicit function template instantiation.

> T first(T)(T[] arr)
> {
>     return arr[0];
> }
>
> auto one = first([1,2,3]);

	-- Daniel

-- 
int getRandomNumber()
{
    return 4; // chosen by fair dice roll.
              // guaranteed to be random.
}

http://xkcd.com/

v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D
i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP  http://hackerkey.com/


More information about the Digitalmars-d-learn mailing list