I'm very newbie with Clojure, and for practice I am trying to apply a simple algorithm for semi random numbers.
A few days ago, I read about loops in the docs of clojure, and how they work using recur
, so I tried to write a loop with this lines of code:
(def numbers_semi_random
(fn []
(loop[Xn 4 count 0]
(while (and (not (= Xn m)) (< count m))
(println (mod (+ (* 5.0 Xn) 7.0) m))
(recur (mod (+ (* 5.0 Xn) 7.0) m) (inc count))
))))
But when I execute the code, this error is displayed
CompilerException java.lang.UnsupportedOperationException: Can only recur from tail position, compiling
What's happening? recur
is not in the tail of the function?