I'm a Clojure novice working through 4Clojure problems. In one problem I am supposed to create a function that takes a number and returns that number of Fibonaccis. My first thought was to create a function that creates a lazy sequence of Fibonaccis and then just takes however many it needs. Here is what I came up with:
(fn [numberOfFibs] (defn lazyFib [a b] (cons a (lazy-seq (lazyFib b (+ b a))))) (take numberOfFibs (lazyFib 1 1)))
This did work in my IDE but it wasn't accepted by 4Clojure due to the private defn. defs are not accepted by the website.
How can I refactor this function to remove the defn? And what are the problems with style and readability? Is it easy to reason about the function?