Re: Fibonacci with ranges

2011-03-12 Thread Jonathan M Davis
On Saturday 12 March 2011 02:48:19 Russel Winder wrote: > Jonathan, > > On Sat, 2011-03-12 at 10:31 +, Russel Winder wrote: > [ . . . ] > > > > What's happening is that the parameter that you're passing n to for > > > recurrence is size_t. And on 32-bit systems, size_t is uint, so > > > passi

Re: Fibonacci with ranges

2011-03-12 Thread Russel Winder
Jonathan, On Sat, 2011-03-12 at 10:31 +, Russel Winder wrote: [ . . . ] > > What's happening is that the parameter that you're passing n to for > > recurrence > > is size_t. And on 32-bit systems, size_t is uint, so passing n - which is > > long - > > to recurrence would be a narrowing con

Re: Fibonacci with ranges

2011-03-12 Thread Jonathan M Davis
On Saturday 12 March 2011 02:31:20 Russel Winder wrote: > Jonathan, > > Thanks for the info, very helpful. One point though: > > On Sat, 2011-03-12 at 01:56 -0800, Jonathan M Davis wrote: > [ . . . ] > > > What's happening is that the parameter that you're passing n to for > > recurrence is siz

Re: Fibonacci with ranges

2011-03-12 Thread Russel Winder
On Sat, 2011-03-12 at 02:15 -0800, Ali Çehreli wrote: [ . . . ] > void main() > { > long[] data = [ 0, 1, 1, 2, 3, 5, 8 ]; > > foreach (n; 0 .. data.length) { > assert(equal(declarative(n), data[0..n])); > } > } In fact the driver is: unittest { immutable data = [ [

Re: Fibonacci with ranges

2011-03-12 Thread Russel Winder
Jonathan, Thanks for the info, very helpful. One point though: On Sat, 2011-03-12 at 01:56 -0800, Jonathan M Davis wrote: [ . . . ] > What's happening is that the parameter that you're passing n to for > recurrence > is size_t. And on 32-bit systems, size_t is uint, so passing n - which is >

Re: Fibonacci with ranges

2011-03-12 Thread Ali Çehreli
On 03/12/2011 01:33 AM, Russel Winder wrote: > On Fri, 2011-03-11 at 18:46 -0500, Jesse Phillips wrote: >> Without testing: foreach (f; take(recurrence!("a[n-1] + a[n-2]")(0UL, 1UL), 50)) >> >> teo Wrote: >> >>> Just curious: How can I get ulong here? >>> >>> foreach (f; take(recurrence!("a[n-1]

Re: Fibonacci with ranges

2011-03-12 Thread Jonathan M Davis
On Saturday 12 March 2011 01:33:34 Russel Winder wrote: > On Fri, 2011-03-11 at 18:46 -0500, Jesse Phillips wrote: > > Without testing: foreach (f; take(recurrence!("a[n-1] + a[n-2]")(0UL, > > 1UL), 50)) > > > > teo Wrote: > > > Just curious: How can I get ulong here? > > > > > > foreach (f; take

Re: Fibonacci with ranges

2011-03-12 Thread Russel Winder
On Sat, 2011-03-12 at 09:33 +, Russel Winder wrote: [ . . . ] > Interestingly, or not, the code: > > long declarative ( immutable long n ) { > return take ( recurrence ! ( "a[n-1] + a[n-2]" ) ( 0L , 1L ) , n ) ; > } > > results in the return statement delivering: > > rdmd --main -unittest

Re: Fibonacci with ranges

2011-03-12 Thread Russel Winder
On Fri, 2011-03-11 at 18:46 -0500, Jesse Phillips wrote: > Without testing: foreach (f; take(recurrence!("a[n-1] + a[n-2]")(0UL, 1UL), > 50)) > > teo Wrote: > > > Just curious: How can I get ulong here? > > > > foreach (f; take(recurrence!("a[n-1] + a[n-2]")(0, 1), 50)) > > { > > writeln(f)

Re: Fibonacci with ranges

2011-03-11 Thread Jesse Phillips
Without testing: foreach (f; take(recurrence!("a[n-1] + a[n-2]")(0UL, 1UL), 50)) teo Wrote: > Just curious: How can I get ulong here? > > foreach (f; take(recurrence!("a[n-1] + a[n-2]")(0, 1), 50)) > { > writeln(f); > }

Fibonacci with ranges

2011-03-11 Thread teo
Just curious: How can I get ulong here? foreach (f; take(recurrence!("a[n-1] + a[n-2]")(0, 1), 50)) { writeln(f); } Results: 0 1 1 2 3 5 8 .. 1134903170 1836311903 -1323752223 512559680 -811192543