I have been trying to implement a list of Fibonacci number sequence from 0 to n without using the lazy zipwith
method. What I have so far is code that returns a list from n
to 1. Is there any way I can change this code so it returns the list from 0-n
at all?
Example:
fib_seq 4 = [3,2,1,1]
-- output wanted: [1,1,2,3]
If there is not a way to do what I want the code to do, is there a way to just return the list of Fibonacci numbers taking in a number say again 4 it would return [0, 1, 1, 2]
.
fib_seq :: Int -> [Int]
fib_seq 0 = [0]
fib_seq 1 = [1]
fib_seq n = sum (take 2 (fib_seq (n-1))) : fib_seq (n-1)