Lists

Lists are most commonly used in Clojure to represent code. However, they are singly linked lists with efficient access and modifications of the list head, but slow random access. They have their own type, clojure.lang.IPersistentList. They’re often used interchangeably with sequences, but we can find out if a collection is a list by calling the core function, list?.

How to instantiate a list

Clojure has no literal representation for lists because they’re interpreted as code. So we need to quote it to make it a list. But the problem with quoting is that it won’t evaluate the elements of the list, so this representation is only useful in lists of literals.

Get hands-on with 1200+ tech skills courses.