Introduction

Resursion is an important technique in programming, especially in functional programming.

Simple examples:

  1. fact :: Integer -> Integer
  2. fact 0 = 1
  3. fact n = n * fact (n - 1)
  4. > fact 10
  5. 3628800
  6. > fact 5
  7. 120
  8. fib :: Integer -> Integer
  9. fib 0 = 1
  10. fib 1 = 1
  11. fib n = fib (n - 1) + fib (n - 2)
  12. > fib 10
  13. 89
  14. > fib 5
  15. 8