You are so right, the answer seems obvious now :)
Thanks,
Witold Szczerba
On Sat, Dec 19, 2015 at 1:57 AM, Herwig Hochleitner
wrote:
> Use a function instead of the loop:
>
> (defn ws [req]
> (with-channel req channel
> ((fn loop-f [x]
>
Hi,
I am doing my first steps in Clojure and I have a problem with "recur".
Here's an example of the HTTP Kit's handler I just wrote to test drive the
first Clojure piece of code of mine:
(defn ws [req]
(with-channel req channel
(loop [x 1]
(timer/schedule-task
3000
Use a function instead of the loop:
(defn ws [req]
(with-channel req channel
((fn loop-f [x]
(timer/schedule-task
3000
(println x)
(loop-f (+ x 1
0)))
loop-recur is used to prevent unbounded stack growth, but the timer task
acts as a sort of