Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Common Lisp
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Data structures=== ''Sequence'' types in Common Lisp include lists, vectors, bit-vectors, and strings. There are many operations that can work on any sequence type. As in almost all other Lisp dialects, ''lists'' in Common Lisp are composed of ''conses'', sometimes called ''cons cells'' or ''pairs''. A cons is a data structure with two slots, called its ''car'' and ''cdr''. A list is a linked chain of conses or the empty list. Each cons's car refers to a member of the list (possibly another list). Each cons's cdr refers to the next cons—except for the last cons in a list, whose cdr refers to the <code>nil</code> value. Conses can also easily be used to implement trees and other complex data structures; though it is usually advised to use structure or class instances instead. It is also possible to create circular data structures with conses. Common Lisp supports multidimensional ''arrays'', and can dynamically resize ''adjustable'' arrays if required. Multidimensional arrays can be used for matrix mathematics. A ''vector'' is a one-dimensional array. Arrays can carry any type as members (even mixed types in the same array) or can be specialized to contain a specific type of members, as in a vector of bits. Usually, only a few types are supported. Many implementations can optimize array functions when the array used is type-specialized. Two type-specialized array types are standard: a ''string'' is a vector of characters, while a ''bit-vector'' is a vector of [[bit]]s. ''[[Hash table]]s'' store associations between data objects. Any object may be used as key or value. Hash tables are automatically resized as needed. ''Packages'' are collections of symbols, used chiefly to separate the parts of a program into [[namespaces]]. A package may ''export'' some symbols, marking them as part of a public interface. Packages can use other packages. ''Structures'', similar in use to [[C (programming language)|C]] structs and [[Pascal (programming language)|Pascal]] records, represent arbitrary complex data structures with any number and type of fields (called ''slots''). Structures allow single-inheritance. ''Classes'' are similar to structures, but offer more dynamic features and multiple-inheritance. (See [[Common Lisp Object System|CLOS]]). Classes have been added late to Common Lisp and there is some conceptual overlap with structures. Objects created of classes are called ''Instances''. A special case is Generic Functions. Generic Functions are both functions and instances.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)