Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
6
Task/Fibonacci-sequence/Clojure/fibonacci-sequence-3.clj
Normal file
6
Task/Fibonacci-sequence/Clojure/fibonacci-sequence-3.clj
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(defn fibs []
|
||||
(map first ;; throw away the "metadata" (see below) to view just the fib numbers
|
||||
(iterate ;; create an infinite sequence of [prev, curr] pairs
|
||||
(fn [[a b]] ;; to produce the next pair, call this function on the current pair
|
||||
[b (+ a b)]) ;; new prev is old curr, new curr is sum of both previous numbers
|
||||
[0 1]))) ;; recursive base case: prev 0, curr 1
|
||||
Loading…
Add table
Add a link
Reference in a new issue