4 ms·
Named anonymous functions are there to allow you to call the function recursively while inside it. i.e. (= ((fn factorial [x] (if (<= x 1)
by emidln 12y ago
Named anonymous functions are there to allow you to call the function recursively while inside it.
i.e.
(= ((fn factorial [x]
(if (<= x 1)
1
(* x (factorial (dec x))))) 5)
120)
Note, this isn't run under TCO (see loop/recur).
- ufo 12y agoAlso, in your example, the recursive call is not in tail position. You would first need to rewrite it to use an acumulator parameter.