clojure - repeat function n times in recursion on input (without loop recur) -
i know can solve problem loop , recur seems such simple (common?) operation wondering if there no single function in clojure or less cluttered approach loop/ recur solve this. searched not able find something.
the function looking following.
(the-function n input some-function)
where n number of time recursivle call some-function on input.
a simple example be:
(the-function 3 1 (fn [x] (+ x 1))) => 4
is ther in clojure?
best regards
what want iterate
. generate infinite sequence of repeated applications of function seed input. replicate behavior describe here, write:
(nth (iterate some-function input) n)
Comments
Post a Comment