I wrote the following code to create a list containing Fibonacci numbers.
fibonacci = [a + b | a <- 1:fibonacci, b <- 0:1:fibonacci]
I expect the output of the list to be [1,2,3,5,8,13..], however the output is not a Fibonacci sequence.
I can’t understand why this is not working.
My reasoning is that if the Fibonacci numbers [1,2,3,5,8,13..], then this will be equal to the sum of 2 lists [1,1,2,3,5,8,13..]and [0,1,1,2,3,5,8,13..], which are equivalent to 1:[1,2,3,5,8,13..]and 0:1:[1,2,3,5,8,13..]or 1:fibonacciand0:1:fibonacci
I was looking for other ways to implement this sequence, however I would really like to know why my code does not work.