Chain call in clojure?
- by Konrad Garus
I'm trying to implement sieve of Eratosthenes in Clojure. One approach I would like to test is this:
Get range (2 3 4 5 6 ... N)
For 2 <= i <= N
Pass my range through filter that removes multiplies of i
For i+1th iteration, use result of the previous filtering
I know I could do it with loop/recur, but this is causing stack overflow errors (for some reason tail call optimization is not applied).
How can I do it iteratively? I mean invoking N calls to the same routine, passing result of ith iteration to i+1th.