Re: Re[Haskell-cafe] duction Sequence of simple Fibonacci sequence implementation

2009-08-28 Thread Luke Palmer
On Fri, Aug 28, 2009 at 3:54 AM, staafmeister wrote: > Thanks for the memo trick! Now I understand that the haskell compiler > cannot memoize functions of integers, because it could change the space > behaviour. However I think it could memoize everything else. Because all > types that are data obj

Re[2]: Re[Haskell-cafe] duction Sequence of simple Fibonacci sequence implementation

2009-08-28 Thread Bulat Ziganshin
Hello staafmeister, Friday, August 28, 2009, 1:54:38 PM, you wrote: it just works other way. imagine a whole haskell program as a graph. i.e. expression 1+2, for example, forms a node with (=) in its root and 1 and 2 as its subtrees. computation of program is a series of graph reductions, replaci

Re: Re[Haskell-cafe] duction Sequence of simple Fibonacci sequence implementation

2009-08-28 Thread staafmeister
Thanks for the memo trick! Now I understand that the haskell compiler cannot memoize functions of integers, because it could change the space behaviour. However I think it could memoize everything else. Because all types that are data objects sitting in memory (so the arg is essentially a referen

Re: Re[Haskell-cafe] duction Sequence of simple Fibonacci sequence implementation

2009-08-27 Thread Daniel Fischer
Am Donnerstag 27 August 2009 21:41:49 schrieb Jason Dagit: > On Thu, Aug 27, 2009 at 12:32 PM, Bulat > > Ziganshin wrote: > > Hello SimonK77, > > > > Thursday, August 27, 2009, 11:24:14 PM, you wrote: > > > > for linear timing it needs memoization of previous results. haskell > > compilers doesn't

Re: Re[Haskell-cafe] duction Sequence of simple Fibonacci sequence implementation

2009-08-27 Thread Bulat Ziganshin
Hello SimonK77, Thursday, August 27, 2009, 11:24:14 PM, you wrote: list-based memoization for fibs should look as fibs = 1 : 1 : map (sum.take 2) (tails fibs) > Hallo everyone, > as Haskell uses the Lazy Evaluation reduction policy also known > as Outermost Graph Reduction, I was wondering i

Re: Re[Haskell-cafe] duction Sequence of simple Fibonacci sequence implementation

2009-08-27 Thread Jason Dagit
On Thu, Aug 27, 2009 at 12:32 PM, Bulat Ziganshin wrote: > Hello SimonK77, > > Thursday, August 27, 2009, 11:24:14 PM, you wrote: > > for linear timing it needs memoization of previous results. haskell > compilers doesn't do it automatically since it may change space > properties of program. well-k

Re: Re[Haskell-cafe] duction Sequence of simple Fibonacci sequence implementation

2009-08-27 Thread Bulat Ziganshin
Hello SimonK77, Thursday, August 27, 2009, 11:24:14 PM, you wrote: for linear timing it needs memoization of previous results. haskell compilers doesn't do it automatically since it may change space properties of program. well-known example is: main = print (sum[1..1000] + prod[1..1000]) in ord

Re[Haskell-cafe] duction Sequence of simple Fibonacci sequence implementation

2009-08-27 Thread SimonK77
Hallo everyone, as Haskell uses the Lazy Evaluation reduction policy also known as Outermost Graph Reduction, I was wondering if the following simple implementation of the Fibonacci sequence would result in linear runtime behaviour. fib :: Integer -> Integer fib 0 = 0 fib 1 = 1 fib n = fib