Skip to content

Commit

Permalink
Continued example seq code.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrwizard82d1 committed Aug 5, 2014
1 parent ea89ffd commit 66ae153
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ch-03/src/ch_03/sequences.clj
Expand Up @@ -58,6 +58,15 @@
" "
(conj rst 42)))))

(defn do-seq-not-list
[]
(println " Counting a seq is SLOW....")
(let [s (range 1e6)]
(time (count s)))
(println " ...but counting a list is very fast.")
(let [s (apply list (range 1e6))]
(time (count s))))

(defn do-all
[]
(println)
Expand All @@ -77,4 +86,7 @@
(do-rest-next)
(println)
(println " Seqs are not iterators")
(do-seq-not-iterator))
(do-seq-not-iterator)
(println)
(println " Seqs are not lists")
(do-seq-not-list))

0 comments on commit 66ae153

Please sign in to comment.