|
cons
|
Construct cell structure for building linked lists. More...
#include <cons.h>

Data Fields | |
| void * | car |
| Contents of Address Register (CAR). | |
| struct cons * | cdr |
| Contents of Decrement Register (CDR). | |
Construct cell structure for building linked lists.
The car field holds data, the cdr field points to the next cons cell.
A cons cell is a fundamental data structure in Lisp-like languages, where it is used to build lists and other complex data structures. The car field holds the actual data or value, while the cdr field points to the next cons cell in the list, allowing for the construction of linked lists and other complex data structures of arbitrary length.
Why "cons"? The term "cons" is derived from the word "construct," as cons cells are used to construct lists and other data structures. The cons function is a fundamental operation in Lisp that prepends an already-existing cons cell, allowing programmers to build complex data structures by linking cons cells together. The name reflects the purpose of the data structure, which is to construct and manipulate lists and other composite data types.
What does CAR and CDR mean? CAR stands for "Contents of Address Register" and CDR stands for "Contents of Decrement Register." These terms originate from the early days of Lisp programming and refer to the two parts of a cons cell.
| void* cons::car |
Contents of Address Register (CAR).
Data field (can hold any type).
The car field of a cons cell is a versatile component that can hold any type of data. It serves as the primary pointer-sized storage for the value or data associated with the cons cell; this optionally includes sub-cons cells recursively.
| struct cons* cons::cdr |