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
; 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 |