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.
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
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
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
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
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
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
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
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