[Haskell-cafe] Python vs Haskell in tying the knot

Cristiano Paris frodo at theshire.org
Fri Jul 17 08:00:53 EDT 2009

On Fri, Jul 17, 2009 at 12:41 PM, Cristiano Paris<frodo at theshire.org> wrote:
> ...
> Now, to confirm my hypothesis, I wrote a slight different version of
> fib, like follows:
> fib' n = 1:1:(fib' n) `plus` (tail $ fib' n) where plus = zipWith (+)
> i.e. I inserted a fictious argument n in the definition of fib'.
> Now, if I try "take 30 $ fib' 100", it takes significntly longer than
> "take 30 fib": specifically, the latter is instantaneous, while the
> former takes about 5 seconds to complete on my MacBook Pro. Is this an
> evidence that the "tying the knot" process is going on in the first
> version?

BTW, after a -O2 compilation, fib' is apparently as fast a fib.


More information about the Haskell-Cafe mailing list