Re: filter sequence until false result

2010-03-13 Thread Matt
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

Re: filter sequence until false result

2010-03-13 Thread Matt
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 -

Re: filter sequence until false result

2010-03-13 Thread Michał Marczyk
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

Re: filter sequence until false result

2010-03-13 Thread CuppoJava
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

filter sequence until false result

2010-03-13 Thread Glen Rubin
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