--
R. Mark Volkmann
Object Computing, Inc.
How is it different if you change "doall" to "dorun"? According to
their doc strings, they both "can be used to force any effects. Walks
through the successive rests of the seq"
>> 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 it different if you change "doall" to "dorun"? According to
> their doc strings, they both "can be used to force any effects. Walks
> through the successive rests of the seq"
Using doall will cause read-my-file to return a seq of all the lines.
dorun will return nil.
Here's a simpler example:
user=> (doall (map #(do (prn %) %) [1 2 3]))
1
2
3
(1 2 3)
user=> (dorun (map #(do (prn %) %) [1 2 3]))
1
2
3
nil
user=>
(Note the difference in return value.)
--Steve
--