Re: how implement takeWhile

2012-08-06 Thread Simen Kjaeraas
On Mon, 06 Aug 2012 17:49:19 +0200, Philippe Sigaud wrote: On Mon, Aug 6, 2012 at 5:32 PM, Philippe Sigaud wrote: What I'd like to know and may test myself is: is there any speed difference in this functional-oriented D code and a more standard (C-ish) way to obtain the same result? Here

Re: how implement takeWhile

2012-08-06 Thread Philippe Sigaud
On Mon, Aug 6, 2012 at 5:32 PM, Philippe Sigaud wrote: > What I'd like to know and may test myself is: is there any speed > difference in this functional-oriented D code and a more standard > (C-ish) way to obtain the same result? Here it is. Answer: no noticeable difference. The functional way

Re: how implement takeWhile

2012-08-06 Thread Philippe Sigaud
On Mon, Aug 6, 2012 at 3:17 PM, Russel Winder wrote: >> > Do a JVM backend to D and D could wipe the floor with Scala :-) >> >> Why is that? Can't Scala do the same? > > Scala can definitely do the same, possibly more, but it's syntax gets > annoying and compilation time is horrendous. >From wha

Re: how implement takeWhile

2012-08-06 Thread Russel Winder
On Mon, 2012-08-06 at 15:13 +0200, Tobias Pankrath wrote: > On Monday, 6 August 2012 at 13:10:50 UTC, Russel Winder wrote: > > On Mon, 2012-08-06 at 12:15 +0200, Simen Kjaeraas wrote: > > […] > >> writeln(recurrence!((a,n)=>a[n-1]+a[n-2])(1,1).until!(a=>a>=4)().filter!(a=>a%2==0)().reduce!((a,b

Re: how implement takeWhile

2012-08-06 Thread Tobias Pankrath
On Monday, 6 August 2012 at 13:10:50 UTC, Russel Winder wrote: On Mon, 2012-08-06 at 12:15 +0200, Simen Kjaeraas wrote: […] writeln(recurrence!((a,n)=>a[n-1]+a[n-2])(1,1).until!(a=>a>=4)().filter!(a=>a%2==0)().reduce!((a,b)=>a+b)()) Do a JVM backend to D and D could wipe the floor with Sca

Re: how implement takeWhile

2012-08-06 Thread Russel Winder
On Mon, 2012-08-06 at 12:15 +0200, Simen Kjaeraas wrote: […] > writeln(recurrence!((a,n)=>a[n-1]+a[n-2])(1,1).until!(a=>a>=4)().filter!(a=>a%2==0)().reduce!((a,b)=>a+b)()) Do a JVM backend to D and D could wipe the floor with Scala :-) -- Russel. =

Re: how implement takeWhile

2012-08-06 Thread Simen Kjaeraas
On Mon, 06 Aug 2012 11:59:29 +0200, Simen Kjaeraas wrote: This is what you want, isn't it? recurrence!((a,n)=>a[n-1]+a[n-2])(1,1).until!(a=>a>=4)() That is, the meat of it. The full line: writeln(recurrence!((a,n)=>a[n-1]+a[n-2])(1,1).until!(a=>a>=4)().filter!(a=>a%2==0)().reduce!

Re: how implement takeWhile

2012-08-06 Thread Simen Kjaeraas
On Mon, 06 Aug 2012 11:53:18 +0200, bioinfornatics wrote: Dear, 1/ i would like have a code near as this haskell code: fibs = 1 : 1 : zipWith (+) fibs (tail fibs) main = do print $ sum (filter even (takeWhile (<400) fibs)) Ii know in D: - auto fib = recurrence!("a[n-1] + a[

how implement takeWhile

2012-08-06 Thread bioinfornatics
Dear, 1/ i would like have a code near as this haskell code: fibs = 1 : 1 : zipWith (+) fibs (tail fibs) main = do print $ sum (filter even (takeWhile (<400) fibs)) Ii know in D: - auto fib = recurrence!("a[n-1] + a[n-2]")(1, 1); - std.algorithm.until - std.algorithm.filler - st