May 2018
Beginner to intermediate
290 pages
6h 43m
English
So if vectors and lists are both ordered, sequential data structures, why have both? The reason Clojure includes both vectors and lists is that while they are similar on the outside, internally these two data structures are very different. As shown in the next figure, you can think of a vector as similar to an array, a big chunk of continuous memory. Just put the first item in the first slot of your block of memory, the second item in the second, and so on.

Lists, by contrast, are implemented as linked lists—hence the name. As illustrated in the figure, you can think of a list as a series of two-slot objects.
One slot contains ...
Read now
Unlock full access