Hmm.. I should re-read messages before sending them. The correct code
is:
(take-while #(< % 20) primes)
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are
I think what you want is take-while instead of filter:
(take-while %(< % 20) primes)
-Matt
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated -
On 13 March 2010 15:49, Glen Rubin wrote:
> If I try:
>
> (filter #(while (< % 20)) primes)
>
> It gets hung up since filter keeps testing primes, despite the fact
> that they have grown too large. So, I would like filter to stop at
> the first false result.
Actually that's not what happens. Exe
You can use either take-while or for to do what you want.
(take-while #(< % 20) primes)
(for [p primes :while (< p 20)] p)
Hope that helps
-Patrick
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@google
Hey all!
I am trying to filter a sequence until a false value is returned. Is
there a control-flow form to do this? ( I know I could write a loop
statement to do it)
Here are more details of what I am actually trying to do, in case
above is not clear.
input is the lazy sequence of primes:
(u