Created
January 28, 2014 10:00
-
-
Save martintrojer/8664969 to your computer and use it in GitHub Desktop.
fibs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn fib-seq [b1 b2] | |
(lazy-seq | |
(cons b2 (fib-seq b2 (+ b1 b2))))) | |
(def fibs (fib-seq 0 1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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