May 2018
Beginner to intermediate
290 pages
6h 43m
English
Along with the literal syntax there is also a function that manufactures vectors, called, appropriately enough, vector. The vector function takes any number of any kind of argument and wraps a vector around those arguments:
| | ;; The same as [true 3 "four" 5] |
| | |
| | (vector true 3 "four" 5) |
| | |
| | ;; The same as [] |
| | |
| | (vector) |
However you conjure it up, once you have a vector you’ll want to do stuff with it. Fortunately, Clojure provides all sorts of useful functions to go with your vectors. For example, if you’re interested in how many items are hiding inside your vector you can use our old friend count:
| | (def novels ["Emma" "Coma" "War and Peace"]) |
| | |
| | (count novels) ; Returns 3. |
You can get at the first item ...
Read now
Unlock full access