cons
Loading...
Searching...
No Matches
Data Fields
cons Struct Reference

Construct cell structure for building linked lists. More...

#include <cons.h>

Collaboration diagram for cons:
Collaboration graph
[legend]

Data Fields

void * car
 Contents of Address Register (CAR).
 
struct conscdr
 Contents of Decrement Register (CDR).
 

Detailed Description

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.

Definition at line 73 of file cons.h.

Field Documentation

◆ car

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.

Definition at line 83 of file cons.h.

◆ cdr

struct cons* cons::cdr

Contents of Decrement Register (CDR).

Pointer to the next cons cell (or CONS_NIL).

Definition at line 89 of file cons.h.


The documentation for this struct was generated from the following file: