On May 31, 2012, at 9:14 AM, michaelr524 wrote:
> Why the following triggers infinite realization of the infinite lazy
> seq
You've catted together an infinite seq of empty seqs, and forcing a lazy seq
doesn't stop until either an element or known emptiness is found, whereas you
provide neithe
Hi,
This has probably been asked a million times but I couldn't find
anything.
Why the following triggers infinite realization of the infinite lazy
seq and how I can work around it and make it stop when f1 returns an
empty seq,
(defn f1 [] (println "hello") [])
(defn f2 [] (la
While fibs is a nice small example, it is not idiomatic Clojure.
Pointing the fibs var to the head of the list keeps the whole list in
memory as it realizes. Better is to expose fibs as a *function* return
the sequence, so the head is not retained.
(defn fibo []
(map first (iterate (fn [[
cool - thanks guys for the detailed reply. crystal clear now -:)
Thx
swaroop
--~--~-~--~~~---~--~~
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
Swaroop,
> Just started learning clojure recently - initial examples were easy to
> understand, until I found this example
>
> fibonacci sequence using lazy-cat :
> (def fibs (lazy-cat [0 1] (map + fibs (rest fibs
>
> I am trying to understand how this works ..not su
Hi swaroop,
2009/7/29 swaroop belur :
>
> fibonacci sequence using lazy-cat :
> (def fibs (lazy-cat [0 1] (map + fibs (rest fibs
>
> I am trying to understand how this works ..not sure i fully comprehend
> it.
>
> Can anyone please explain how clojure evaluates thi
Hello all,
Just started learning clojure recently - initial examples were easy to
understand, until I found this example
fibonacci sequence using lazy-cat :
(def fibs (lazy-cat [0 1] (map + fibs (rest fibs
I am trying to understand how this works ..not sure i fully comprehend
it.
Can
ast for irc,
>> if not for private correspondance only.
>>
>> My 0,02 € (but being from a "dog people", maybe this does not count as
>> if it had been written by a not "dog people" ?),
>>
>> --
>> Laurent
>>
>> > Laz
Hi,
Am 16.05.2009 um 22:42 schrieb Sean Devlin:
I was making a joke about housecats.
Argh. Sorry. I always pronounce "cat" in german
rather than english. Some strange tick of mine.
So I didn't get the play of words.
Sincerely
Meikel
smime.p7s
Description: S/MIME cryptographic signature
I was making a joke about housecats.
Maybe I should file a bug report saying cat should default to being
lazy :)
Again, sorry for the confusion.
On May 16, 4:34 pm, Meikel Brandmeyer wrote:
> Hi,
>
> Am 16.05.2009 um 21:58 schrieb Sean Devlin:
>
> > Lazy cat is redundant.
Hi,
Am 16.05.2009 um 21:58 schrieb Sean Devlin:
Lazy cat is redundant.
concat != lazy-cat. lazy-cat is obviously not redundant.
Sincerely
Meikel
smime.p7s
Description: S/MIME cryptographic signature
private correspondance only.
>
> My 0,02 € (but being from a "dog people", maybe this does not count as
> if it had been written by a not "dog people" ?),
>
> --
> Laurent
>
> > Lazy cat is redundant.
>
> > On May 16, 3:55 pm, Meikel Brand
en written by a not "dog people" ?),
--
Laurent
> Lazy cat is redundant.
>
> On May 16, 3:55 pm, Meikel Brandmeyer wrote:
>> Hi,
>>
>> Am 16.05.2009 um 21:48 schrieb George Jahad:
>>
>> > I can't come up with a reason to use lazy-cat ove
Clearly you are all dog people. Lazy cat is redundant.
On May 16, 3:55 pm, Meikel Brandmeyer wrote:
> Hi,
>
> Am 16.05.2009 um 21:48 schrieb George Jahad:
>
> > I can't come up with a reason to use lazy-cat over concat. Is it
> > just around for backwards c
Hi,
Am 16.05.2009 um 21:48 schrieb George Jahad:
I can't come up with a reason to use lazy-cat over concat. Is it
just around for backwards compatibility, or am I missing something?
(defmacro lazy-cat
[& colls]
`(concat ~@(map #(list `lazy-seq %) colls)))
There is a difference!
I can't come up with a reason to use lazy-cat over concat. Is it
just around for backwards compatibility, or am I missing something?
(defmacro lazy-cat
[& colls]
`(concat ~@(map #(list `lazy-seq %) colls)))
Thanks,
George
--~--~-~--~~~---~--~
Hi,
Am 31.01.2009 um 15:55 schrieb André Thieme:
On 31 Jan., 02:47, Jason Wolfe wrote:
I think this behavior is as-intended, although I agree that it is
confusing.
I am worried that you could be right.
That’s why I suggested to modify the doc string of lazy-cat.
In my opinion the real
On 31 Jan., 02:47, Jason Wolfe wrote:
> I think this behavior is as-intended, although I agree that it is
> confusing.
I am worried that you could be right.
That’s why I suggested to modify the doc string of lazy-cat.
In my opinion the real step that needs to be done is to go away
from
Daniel Renfer wrote:
>> user=> (take 0 (lazy-cat [(println 10)] [(println 20)]))
>> 10
>> nil
>>
>> What you see here is not an issue with lazy-cat, but rather an issue
>> with take. The current implementation of take evaluates one more than
>> the n
On 31 Jan., 02:44, Daniel Renfer wrote:
> user=> (take 0 (lazy-cat [(println 10)] [(println 20)]))
> 10
> nil
>
> What you see here is not an issue with lazy-cat, but rather an issue
> with take. The current implementation of take evaluates one more than
> the n passed
On Jan 30, 5:44 pm, Daniel Renfer wrote:
> user=> (take 0 (lazy-cat [(println 10)] [(println 20)]))
> 10
> nil
>
> What you see here is not an issue with lazy-cat, but rather an issue
> with take. The current implementation of take evaluates one more than
> the n pas
I think this behavior is as-intended, although I agree that it is
confusing.
The reason for this stems from the fact that lazy-cat returns a seq,
and the only allowed representation for the empty seq is "nil" (i.e.,
Java null). Thus, lazy-cat must always do enough evaluation to know
user=> (take 0 (lazy-cat [(println 10)] [(println 20)]))
10
nil
What you see here is not an issue with lazy-cat, but rather an issue
with take. The current implementation of take evaluates one more than
the n passed to it.
So in this case, 1 element of the seq is evaluated and "10&quo
il it is
needed."
I would expect that in
(take 0 (lazy-cat [(println 10)] [(println 20)]))
no evaluation is needed. If lazy-cat were lazy it would return
immediately,
without concatenating anything.
Maybe the docstring can get modified?
Although I personally see this current behaviour as n
24 matches
Mail list logo