recursion - Non tail-recursive anonymous functions in Clojure -
how create recursive anonymous function in clojure not tail recursive?
the following doesn't work, recur tail recursive functions. i'm reluctant drag in y-combinator..
((fn [n] (if (= 1 n) 1 (* n (recur (dec n))))) 5)
functions can given name refer specifying between fn , arglist:
user> ((fn ! [n] (if (= 1 n) 1 (* n (! (dec n))))) 5) 120
Comments
Post a Comment