Re: lazy-cat infinite realization on empty seq

2012-06-03 Thread Stephen Compall
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

lazy-cat infinite realization on empty seq

2012-06-02 Thread michaelr524
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

Re: fibonacci sequence using lazy-cat

2009-07-29 Thread Stuart Halloway
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 [[

Re: fibonacci sequence using lazy-cat

2009-07-29 Thread swaroop belur
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

Re: fibonacci sequence using lazy-cat

2009-07-29 Thread Baishampayan Ghose
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

Re: fibonacci sequence using lazy-cat

2009-07-29 Thread Lauri Pesonen
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

fibonacci sequence using lazy-cat

2009-07-29 Thread swaroop belur
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

Re: lazy-cat

2009-05-16 Thread Laurent PETIT
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

Re: lazy-cat

2009-05-16 Thread Meikel Brandmeyer
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

Re: lazy-cat

2009-05-16 Thread Sean Devlin
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.

Re: lazy-cat

2009-05-16 Thread Meikel Brandmeyer
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

Re: lazy-cat

2009-05-16 Thread Sean Devlin
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

Re: lazy-cat

2009-05-16 Thread Laurent PETIT
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

Re: lazy-cat

2009-05-16 Thread Sean Devlin
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

Re: lazy-cat

2009-05-16 Thread Meikel Brandmeyer
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!

lazy-cat

2009-05-16 Thread 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))) Thanks, George --~--~-~--~~~---~--~

Re: Documentation of lazy-cat should contain a warning

2009-01-31 Thread Meikel Brandmeyer
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

Re: Documentation of lazy-cat should contain a warning

2009-01-31 Thread 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 step that needs to be done is to go away from

Re: Documentation of lazy-cat should contain a warning

2009-01-31 Thread Daniel Renfer
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

Re: Documentation of lazy-cat should contain a warning

2009-01-31 Thread André Thieme
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

Re: Documentation of lazy-cat should contain a warning

2009-01-30 Thread Jason Wolfe
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

Re: Documentation of lazy-cat should contain a warning

2009-01-30 Thread Jason Wolfe
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

Re: Documentation of lazy-cat should contain a warning

2009-01-30 Thread Daniel Renfer
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

Documentation of lazy-cat should contain a warning

2009-01-30 Thread André Thieme
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