diff options
author | Edoardo La Greca | 2025-08-24 20:50:34 +0200 |
---|---|---|
committer | Edoardo La Greca | 2025-08-24 20:50:34 +0200 |
commit | f026b40ca1919a36f662b74d754e548e42965469 (patch) | |
tree | c99e17dfe06cfacb7281a4747c564442db66ce8c | |
parent | b1c7f72af59c0de4ed45f3cd182a899a49e3e0b4 (diff) |
add first and second exercise of lecture 6
-rw-r--r-- | lec06/Fibonacci.hs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lec06/Fibonacci.hs b/lec06/Fibonacci.hs new file mode 100644 index 0000000..79f888e --- /dev/null +++ b/lec06/Fibonacci.hs @@ -0,0 +1,15 @@ +-- Exercise 1 + +fib :: Integer -> Integer +fib 0 = 0 +fib 1 = 1 +fib n = (fib (n-1)) + (fib (n-2)) + +fibs1 :: [Integer] +fibs1 = map fib [0..] + +-- Exercise 2 + +fibs2 :: [Integer] +fibs2 = 0 : (map last $ iterate (\l -> [ last l , last l + (last . init) l ]) [0,1]) + |