Chain call in clojure?
Posted
by Konrad Garus
on Stack Overflow
See other posts from Stack Overflow
or by Konrad Garus
Published on 2010-06-05T13:24:19Z
Indexed on
2010/06/05
13:52 UTC
Read the original article
Hit count: 355
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
filterthat removes multiplies ofi - For
i+1th iteration, use result of the previous filtering
- Pass my range through
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.
© Stack Overflow or respective owner