May 2018
Beginner to intermediate
290 pages
6h 43m
English
While lazy—and particularly unbounded— sequences are a powerful programming tool, dealing with them in the REPL has its issues. You certainly don’t want to try to print an entire infinite sequence, either explicitly, like this:
| | user=> (def numbers (iterate inc 1)) |
| | #'user/numbers |
| | |
| | user=> (println numbers) ; Say goodnight! |
or implicitly:
| | user=> numbers ; And that is it! |
Never try to stare into the face of the infinite. This is where the *print-length* dynamic var and set!, both of which we saw back in Chapter 8, Def, Symbols, and Vars, come in handy:
| | user=> (set! *print-length* 10) |
| | 10 |
| | |
| | user=> numbers |
| | (1 2 3 4 5 6 7 8 9 10 ...) |
More subtly, you also need to be careful about side effects when ...
Read now
Unlock full access