lazy thoughts

BCS ao at pathlink.com
Mon Jan 12 10:48:15 PST 2009


Reply to Andrei,

> One nice thing about lazy is that lazy includes eager. If you actually
> want to "eagerize" map, you just call eager against the returned
> range:
> 
> int[] arr = [ 1, 2, 3, 4 ];
> auto squares = eager(map!("a * a")(arr));
> assert(squares == [ 1, 4, 9, 16 ]);

Nice, that covers my major concern as long as it's not doing a lazy eval 
for each member even so.Based on that I'd think making it a property would 
be better.

For some cases, might the computational overhead be the high cost bit rather 
than the alloc? In that cases you might want to have a memoize option as well.





More information about the Digitalmars-d mailing list