On Mon, Oct 27, 2008 at 12:25 PM, Stuart Halloway <[EMAIL PROTECTED]> wrote: > > I think I am missing something here, can you elaborate? > >> By the way, difference is eager, so I'm not sure there's much point in >> using lazy-cat. :-) > > I am using lazy-cat *because* difference is eager. Is that mistaken? > For example, the first expression below returns immediately, and the > second does not. > > (take 1 (lazy-cat [1 2] [(Thread/sleep 10000)])) > (1) > user=> (lazy-cat [1 2] [(Thread/sleep 10000)]) > (1 2 nil)
Hm, no, you've got a good point. I guess I didn't put much thought into that statement. I guess I was thinking that in order to return anything at all, your function already copied both seqs into sets and ran difference once, and so holding off on the second run of difference wasn't worth much. But I guess that may be an inaccurate assumption. Also, I try to be careful to use lazy outer functions when using lazy inner functions, in order to prevent an outer eager function from destroying the laziness of the inner -- but I was wrong in jumping to the conclusion eager inner funcs suggest the use of eager outer funcs. On the other hand by using lazy-cat, the returned object is going to keep references to both full set objects, so that the difference can be computed later. Using an eager concat would allow the larger sets to be gc'ed. Though upon examination of boot.clj, it looks like "concat" is lazy also. And now I'm wondering what the difference is between concat and lazy-cat. So anyway, you're right -- lazy-cat may make sense with eager inner funcs in general and in this case in particular. --Chouser --~--~---------~--~----~------------~-------~--~----~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---