January 2014
Intermediate to advanced
232 pages
5h 11m
English
One nontrivial difference between Clojure and most other languages is the way that the code is structured. In imperative languages, a common practice is for different lines of code to modify shared data, where each line accessing the memory location sees the result of the previous line of code.
For example, if we have a list of integers and we wish to square each one then print the even ones, the following Python code would be perfectly valid:
| | l = [1, 2, 3, 4, 5] |
| | for i in l |
| | i = i*i |
| | |
| | for i in l |
| | if (i mod 2 == 0) |
| | |
| | print l |
In Clojure this interaction is explicit. Instead of creating a shared memory location and then having different functions access it sequentially, we chain functions together and ...
Read now
Unlock full access