Re: Lazy sequence question

2011-12-01 Thread Paweł Łoziński
On 30 Lis, 22:31, Kasper Galschiot Markus kas...@markus.dk wrote: Is conf what you're looking for? http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/... ~Kasper Of course. Thanks! -- You received this message because you are subscribed to the Google Groups Clojure group.

Lazy sequence question

2011-11-30 Thread Paweł Łoziński
Hi everybody, I'd like to create a lazy sequence which has first element x and all the rest from another lazy sequence. I couldn't find a suitable function in the docs. Can somebody give a hint? Best regards PŁ -- You received this message because you are subscribed to the Google Groups

Re: Lazy sequence question

2011-11-30 Thread Kasper Galschiot Markus
Is conf what you're looking for? http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/cons ~Kasper On 11/30/11 2:27 PM, Paweł Łoziński wrote: Hi everybody, I'd like to create a lazy sequence which has first element x and all the rest from another lazy sequence. I couldn't

lazy sequence question

2009-12-09 Thread Mike K
I'm working my way through Programming Clojure and got an unexpected result with sequences: user (take 10 (filter even? (iterate inc 1))) (2 4 6 8 10 12 14 16 18 20) user (take-while #( % 10) (iterate inc 1)) (1 2 3 4 5 6 7 8 9) user (take 10 (filter #( % 10) (iterate inc 1))) ; Evaluation

Re: lazy sequence question

2009-12-09 Thread Mike K
On Dec 9, 10:35 pm, Mike K mbk.li...@gmail.com wrote: The first two work but the third one hangs.  Why? user (take 5 (filter #( % 10) (iterate inc 1))) (1 2 3 4 5) OK, I figured out that it won't hang with taking = 9 elements, which is the total that pass the filter. But shouldn't it give me

Re: lazy sequence question

2009-12-09 Thread Mark Engelberg
There are only 9 items that satisfy your predicate. (take 10 ...) demands a 10th, and it keeps searching the (iterate inc 1) stream forever, endlessly searching for that 10th item it will never find. On Wed, Dec 9, 2009 at 9:41 PM, Mike K mbk.li...@gmail.com wrote: On Dec 9, 10:35 pm, Mike K

Re: lazy sequence question

2009-12-09 Thread Richard Newman
But shouldn't it give me 9 items without hanging when I ask for 10 or more as in the first case? No. take returns a lazy sequence. The printer is trying to realize it in order to print it. It can't be completely realized until it's taken ten elements (at which point it's done, by

Re: lazy sequence question

2009-12-09 Thread Mike K
Neither filter nor take know to abandon their attempt. That's how this   works. Ah, of course. Thanks Mark and Richard! Mike -- 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

Re: lazy sequence question

2009-12-09 Thread ataggart
On Dec 9, 9:46 pm, Mark Engelberg mark.engelb...@gmail.com wrote: There are only 9 items that satisfy your predicate.  (take 10 ...) demands a 10th, and it keeps searching the (iterate inc 1) stream forever, endlessly searching for that 10th item it will never find. Aww. You make it sound so