[Haskell-beginners] fibonacci and concurrent recursion

Christoffer Buchholz christoffer.buchholz at gmail.com
Mon Dec 3 16:05:28 CET 2012


Hi 

I have been looking at this fibonacci implementation:

f = 0:1:(zipWith (+) f (tail f))

and I have been trying to fit it inside my head. I am not quite there yet, though.

I have been tracing the steps manually like this

0:1

[0,1]
[1]

0:1:1

[0,1,1]
[1,1]

0:1:1:2

[0,1,1,2]
[1,1,2]

0:1:1:2:3

[0,1,1,2,3]
[1,1,2,3]

0:1:1:2:3:5

And it is easy to see that it works, but what I do not understand is how the two recursive applications progress. How do they evolve concurrently? For each execution of `f`, `f` will be executed twice. So how does all these results end up in the same list?

I guess a more general way of asking my question is how does concurrent recursion on the same result-set work? 

-- 
Christoffer Buchholz

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20121203/5ce4c9ca/attachment.htm>


More information about the Beginners mailing list