What is the relationship between a vector and a list in Lisp?

I was told that there is only an atom and a list as the main data structure in Lisp, does this mean that the vector in Lisp is some kind of list? Was the vector saved as a list in the base?

+4
source share
2 answers

What you were told was accurate, but perhaps not the clearest description.

In general, Lisp, at least:

* (type-of #(3 4 5)) (SIMPLE-VECTOR 3) * (atom #(3 4 5)) T 

Defined as everything that is not a CONS cell, including vectors, class instances, etc. So yes, a vector is officially considered an β€œatom” in Lisp, so you were told what you were told.

+4
source

As elsewhere, vector is a framework for efficient random access, usually wrapping around an array with some additional features (auto-increment). The list is best suited for sequential access and quick insertion.

+2
source

All Articles