February 2018
Intermediate to advanced
304 pages
7h 11m
English
Most Clojure sequences are lazy; in other words, elements are not calculated until they’re needed. Using lazy sequences has many benefits:
Consider the code and following expression that produces (mostly) prime numbers using wheel factorization:[19]
| | (ns examples.primes) |
| | ;; Taken from clojure.contrib.lazy-seqs |
| | ; primes cannot be written efficiently as a function, because |
| | ; it needs to look back on the whole sequence. contrast with |
| | ; fibs and powers-of-2 which only need a fixed buffer of 1 or 2 |
| | ; previous ... |
Read now
Unlock full access