5. Arrays and Vectors

In theory, everything that can be done with arrays can also be done with lists. But just because lists are the ubiquitous data type in Lisp and Lisp is an abbreviation for “LISt Processing,” you shouldn’t be tempted to use lists exclusively. Lists are extremely flexible and lend themselves incredibly well for prototyping (see Chapter 2), but for many algorithms arrays are the better choice because of their constant-time access characteristics.

Arrays in COMMON LISP have many facets and can be used like arrays in C or JAVA (which are essentially structured, fixed-size memory blocks), but also like arrays in PERL or RUBY (where in a way they behave like lists with array access characteristics). That’s what this section is ...

Get Common Lisp Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.