First off, defn
(and def
) always produce global, top-level bindings of names to values so you should never use them inside another defn
(or def
).
Second, you have:
(
(defn fib_iter ...)
(fib_iter ...)
)
The ( .. )
delineate a function call so you have the first element (the (defn .. )
form) which is then called as a function with the second element (the (fib_iter .. )
form) as an argument. But fib_iter
is declared to take three arguments (i
, fibi_n_prev
, and fibi_n
) and you are effectively calling it with just one argument.
You should use let
for local bindings, so you would have (let [fib_iter (fn [i fibi_n_prev fibi_n] .. )] (fib_iter 1 0 1))
and you should find that will work.