myfibo.hs 202 B

123456789101112131415161718
  1. -- Slide 15
  2. -- Fibonacci recursive
  3. fibo 0 = 1
  4. fibo 1 = 1
  5. fibo n = fibo (n - 2) + fibo (n - 1)
  6. -- Factorial tail evaluation
  7. f n = ft n 1
  8. ft n acc = case n of
  9. 0 -> acc
  10. _ -> ft (n - 1) (acc * n)