Skip to content

Instantly share code, notes, and snippets.

@martintrojer
Created January 28, 2014 10:00
Show Gist options
  • Save martintrojer/8664969 to your computer and use it in GitHub Desktop.
Save martintrojer/8664969 to your computer and use it in GitHub Desktop.
fibs
(defn fib-seq [b1 b2]
(lazy-seq
(cons b2 (fib-seq b2 (+ b1 b2)))))
(def fibs (fib-seq 0 1))
let fib n =
let rec fib’ back1 back2 = function
| 0 -> 0
| 1 -> back1 + back2
| n -> fib’ back2 (back1 + back2) (n – 1)
fib’ 1 0 n
List.map fib [0..10]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment