Casting MapResult

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 15 16:06:17 PDT 2015


On 06/15/2015 12:44 PM, jmh530 wrote:

 > On Monday, 15 June 2015 at 19:32:12 UTC, Baz wrote:

 >> Ah sorry it's you the OP. just get it. So you wanted greedy, didn't 
you ?
 >
 > I suppose I would want whichever has the best performance. Without
 > testing, I'm not sure which one would be better. Thoughts?

There are different levels of lazyness regarding performance. :)

1) map and most algorithms are fully lazy. They don't do anything until 
elements are actually used.

2) Some algorithms that keep their state in struct objects do some work 
in their constructors to prepare the first element for use.

3) 'each' is fully eager. It walks through all elements of the range and 
does something with each of those.

4) 'array' is fully eager but it also creates an array to store all the 
elements in.

There are also semi-eager algorithms like 'asyncBuf' and 'map' in 
std.parallelism that consume the input range in waves.

Ali



More information about the Digitalmars-d-learn mailing list