April 2012
Intermediate to advanced
296 pages
7h 3m
English
The seq abstraction of first/rest applies to anything that there can be more than one of. In the Java world, that includes the following:
Clojure wraps these Java APIs, making the sequence library available for almost everything you do.
If you try to apply the sequence functions to Java collections, you will find that they behave as sequences. Collections that can act as sequences are called seq-able. For example, arrays are seq-able:
; String.getBytes returns a byte array | |
(first (.getBytes "hello")) | |
-> 104 | |
| |
(rest (.getBytes "hello")) | |
-> (101 108 108 111) | |
| |
(cons (int ... |
Read now
Unlock full access