Skip to content

Instantly share code, notes, and snippets.

@ccunning2
ccunning2 / sol.clj
Last active April 1, 2020 00:56
Clojure Solution
; This function will generate a fibonacci sequence of length n
(defn createFib
"Usage: (createFib n), creates a fibonacci sequence of length n"
([length] (createFib length [0 1]))
([length a] (if (= (count a) length) a (recur length (conj a (+' (peek a) (peek (pop a)) ))) )) )
;Notes: The above function is recursive, with multiple 'arity', meaning that it has a definition for multiple numbers of parameters.
;If you call it with one argument (as you are intended to), then it calls the itself with the two beginning numbers of