functional way doing array stuff/ lambda functions

Namal via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Dec 12 15:10:21 PST 2015


Hello guys,

I am still uncertain how to do it right when it comes to lambda 
functions. For instance: how do I multiply all the elements in an 
array ?

int product(const ref int[] arr){

	int p = 1;
	foreach(i;arr)
		p*=i;
	return p;
}




More information about the Digitalmars-d-learn mailing list