I'm new to Haskell, and was wondering what the difference between these two functions are.
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
fib1 = 1 :1 : [a+b | (a,b) <- zip fib1 (tail fib1)]
I would like to know how they are working more clearly.
How I currently understand them is as follows:
I know that zipWith in the first function will apply the addition function to two lists in this case "fibs" and "tail fibs". However I'm confused on how the recursion is working. I know fibs returns a list and tail fibs would be everything except the head of the list. However I guess I'm confused on the intermediate steps and how zipWith is working with this recursively.
In fib1 I have the same question as above for "zip" but also how exactly is this getting applied to "a" and "b". Also why are "a" and "b" in a tuple?
I'm sorry if I haven't been more clear. I appreciate any help people could offer
Thanks in advance