In contrast, defbinding xto f, made (let [x f] ...)no visible inside f. More precisely, the binding to xis performed after the evaluation f. To have recursive definitions, you need to use letfnone that is designed to define functions. Therefore, you can no longer consider fibonaccihow LazySeq, but you can define it as a function that returns LazySeq:
(letfn [(fibonacci []
(lazy-cat [0 1] (map + (fibonacci) (rest (fibonacci)))))]
(take 10 (fibonacci)))
source
share