I need to make loop method, which takes as argument some method name and how many times it will be looped.
Problem is that, i can't use any mutations (def,let and etc) as well as standart clojure functions, except if, inc, dec, println, +, -, = and etc.
Only with SEQ and Recursion !!!
My example:
;; F = some function name, for example, inc, dec, println and etc.
(defn my-loop [f n]
(if (= n 0)
f
(my-loop f (dec n))))
;; Returns 2, instead of 3, because on next iteration argument F = nil :(
(my-loop (inc 1) 2)
Obviously, when recursion is called, argument F is NIL, so how i can return same argument when recursion was called (without hardcode).
(last (take 5 (iterate inc 13)))
? – akond