doall vs. dorun

2009-01-20 Thread Mark Volkmann
Can someone describe a situation where it is preferable to use doall instead of dorun? I see in the documentation that it retains the head and returns it, thus causing the entire seq to reside in memory at one time, but I'm not sure why I'd want that. -- R. Mark Volkmann Object Computing, Inc.

Re: doall vs. dorun

2009-01-20 Thread Nathanael Cunningham
Pretty much any lazy-seq thats reading data from somewhere that might give up on you if you take to long. For example: Your using line-seq to read from a socket, but the sequence wont be read through until the user does something. On Tue, Jan 20, 2009 at 3:32 PM, Mark Volkmann

Re: doall vs. dorun

2009-01-20 Thread Stuart Sierra
On Jan 20, 3:32 pm, Mark Volkmann r.mark.volkm...@gmail.com wrote: Can someone describe a situation where it is preferable to use doall instead of dorun? Here's one: (defn read-my-file [] (with-open [reader (BufferedReader. (FileReader. my-file.txt))] (doall (line-seq reader

Re: doall vs. dorun

2009-01-20 Thread Mark Triggs
In addition to what others have said, I also tend to use doall when working with agent actions that return sequences (i.e. to force any computation to happen in the agent's thread and not in the caller's) Cheers, Mark On Wed, Jan 21, 2009 at 7:32 AM, Mark Volkmann r.mark.volkm...@gmail.com

Re: doall vs. dorun

2009-01-20 Thread Mark Volkmann
On Tue, Jan 20, 2009 at 3:14 PM, Stuart Sierra the.stuart.sie...@gmail.com wrote: On Jan 20, 3:32 pm, Mark Volkmann r.mark.volkm...@gmail.com wrote: Can someone describe a situation where it is preferable to use doall instead of dorun? Here's one: (defn read-my-file [] (with-open

Re: doall vs. dorun

2009-01-20 Thread Stephen C. Gilardi
On Jan 20, 2009, at 5:32 PM, Mark Volkmann wrote: Here's one: (defn read-my-file [] (with-open [reader (BufferedReader. (FileReader. my-file.txt))] (doall (line-seq reader line-seq returns a lazy sequence, but you have to consume that sequence before with-open closes the file. How is

Re: doall vs. dorun

2009-01-20 Thread Cosmin Stejerean
On Tue, Jan 20, 2009 at 4:32 PM, Mark Volkmann r.mark.volkm...@gmail.comwrote: On Tue, Jan 20, 2009 at 3:14 PM, Stuart Sierra the.stuart.sie...@gmail.com wrote: On Jan 20, 3:32 pm, Mark Volkmann r.mark.volkm...@gmail.com wrote: Can someone describe a situation where it is preferable to

Re: doall vs. dorun

2009-01-20 Thread Mark Volkmann
Thanks Steve and Cosmin! I understand it now. On Tue, Jan 20, 2009 at 4:53 PM, Stephen C. Gilardi squee...@mac.com wrote: On Jan 20, 2009, at 5:32 PM, Mark Volkmann wrote: Here's one: (defn read-my-file [] (with-open [reader (BufferedReader. (FileReader. my-file.txt))] (doall (line-seq