I am currently going through the book Clojure for the Brave and True, in an attempt to learn the language, but I'm a bit hung up on lazy seqs, and I'm afraid the book does a poor job explaining them. But, according to the book, something like this:
(defn wait-for-a-bit [arg]
(Thread/sleep 1000))
(defn get-map [seq]
(map wait-for-a-bit seq))
(time (first (get-map [1 2 3 4 5 6 7 8 9 0])))
Should only take about one second to process, because a value for a lazy seq isn't calculated (realized?) until it's accessed. However, when I run the above code, it takes about ten seconds, so clearly, deferred computation isn't happening. I've looked at the docs on clojuredocs.org, and I think I understand lazy-seq's, but I guess just not in the context of map, reduce, etc.
(time (first (get-map (iterate inc 1000))))
which gave me the more intuitive 1 sec response. – user2524973