Is there an elegant way of making a Result eager instead of lazy?

2012-03-20 Thread ixid
I understand the point of lazy evaluation but I often want to use the lazy algorithm library functions in an eager way. Other than looping through them all which feels rather messy is there a good way of doing this? Is there a reason not to allow the following to be automatically treated eage

Re: Is there an elegant way of making a Result eager instead of lazy?

2012-03-20 Thread simendsjo
On Tue, 20 Mar 2012 18:36:46 +0100, ixid wrote: I understand the point of lazy evaluation but I often want to use the lazy algorithm library functions in an eager way. Other than looping through them all which feels rather messy is there a good way of doing this? Is there a reason not to

Re: Is there an elegant way of making a Result eager instead of lazy?

2012-03-20 Thread bearophile
simendsjo: > std.array includes a method, array(), for doing exactly this: > int[] test2 = array(map!"a+a"(test1)); //eager With 2.059 you can write that also in a more readable way, because there is less nesting: int[] test2 = test1.map!q{a + a}().array(); Bye, bearophile

Re: Is there an elegant way of making a Result eager instead of lazy?

2012-03-20 Thread ixid
Thanks, very handy!

Re: Is there an elegant way of making a Result eager instead of lazy?

2012-03-20 Thread Ali Çehreli
On 03/20/2012 10:50 AM, bearophile wrote: > simendsjo: > >> std.array includes a method, array(), for doing exactly this: >> int[] test2 = array(map!"a+a"(test1)); //eager > > With 2.059 you can write that also in a more readable way, because there is less nesting: > > int[] test2 = test1.map!q{

Re: Is there an elegant way of making a Result eager instead of lazy?

2012-03-20 Thread H. S. Teoh
On Tue, Mar 20, 2012 at 02:52:05PM -0700, Ali Çehreli wrote: [...] > By the way, is there a name for "the => syntax"? [...] You just named it. :-) T -- "Real programmers can write assembly code in any language. :-)" -- Larry Wall