You are writing a comment about Reading Files in Clojure, here is a quick summary:
A brief overview to approaches to reading in files in Clojure.
You are responding to this comment written by liwp on November 16th 2009, 08:08.
Something to remember in clojure is that sequences are by default lazy. So if you produce a sequence from reading a file, e.g.
(with-open ...
(map ...))
you have to wrap the sequence producing code in a doall:
(with-open ...
(doall (map ...)))
This will make sure that all the side-effects in the sequence, i.e. reading from the file, are all realised while the file is still open.
doall is not necessary for the reduce examples, because reduce will realise the whole sequence before returning.
-- Lauri
Please be aware that comment forms go stale after one hour.
Comments may make use of LifeFlow MarkDown. Raw html will be escaped.
Quick Introduction to LifeFlow MarkDown Syntax
A highlighted code block:
Other common languages work as well: scheme, python, java, html, etc.
Other markdown syntax: