May 2018
Beginner to intermediate
290 pages
6h 43m
English
As we discovered all the way back in Chapter 1, def is about as simple as programming-language features come. You just hand it a symbol and a value:
| | (def title "Emma") |
And it binds the symbol to the value. We’ve also seen that in contrast to the very local and temporary let, you use def for longer-lasting, more stable name-to-value bindings. Let’s start with the stable part: the rule is that a binding created with def will hang around until either you change it or the program terminates. This makes def perfect for constants:
| | ;; Everyone's favorite universal constant. |
| | |
| | (def PI 3.14) |
| | |
| | ;; Length of a standard book ID. |
| | |
| | (def ISBN-LENGTH 13) |
| | |
| | ;; Company names are more or ... |
Read now
Unlock full access