36#define CONS_NIL ((struct cons *)NULL)
39#define CONS_NIL_P(_cell) ((_cell) == CONS_NIL)
42#define CONS_NOT_NIL_P(_cell) ((_cell) != CONS_NIL)
45#define CONS(_car, _cdr) ((struct cons){.car = (_car), .cdr = (_cdr)})
48#define CONS_NULL CONS(NULL, CONS_NIL)
static struct cons * cons_cdr(const struct cons *cell)
Accessor for the cdr field of a cons cell.
struct cons * cons_delete(struct cons **list, void *car)
Destructively deletes the first cons cell with the specified car value from the list.
void cons_free(struct cons *cell)
Frees a heap-allocated cons cell.
size_t cons_length(const struct cons *cell)
Computes the length of a linked list of cons cells.
void cons_reverse(struct cons **list)
Reverses a linked list of cons cells in place.
#define CONS_NIL
The empty list (a NULL pointer).
static void cons_rplacd(struct cons *cell, struct cons *cdr)
Mutator for the cdr field of a cons cell.
static void * cons_car(const struct cons *cell)
Accessor for the car field of a cons cell.
struct cons ** cons_find(struct cons **list, void *cell)
Finds the first cons cell in a list that matches a given identity.
struct cons * cons_append(struct cons *cell1, struct cons *cell2)
Appends one list of cons cells to another.
struct cons * cons_member(struct cons *cell, void *car)
Returns the first cons cell in a linked list of cons cells whose car field matches the specified valu...
struct cons ** cons_loop(struct cons **list, bool(*pred)(struct cons **list, struct cons *cell, void *user), void *user)
Loops through a list of cons cells, applying a predicate function to each cell.
struct cons * cons_last(struct cons *cell)
Returns the last cons cell in a linked list of cons cells.
struct cons * cons_remove(struct cons **list, struct cons *cell)
Destructively removes the specified cons cell from the list.
struct cons * cons_heap(void *car)
Allocates a new cons cell on the heap.
static void cons_rplaca(struct cons *cell, void *car)
Mutator for the car field of a cons cell.
static void cons_init(struct cons *cell, void *car)
Initialises a cons cell with the given car value and cdr set to CONS_NIL.
struct cons ** cons_prepend(struct cons **list, struct cons *cell)
Prepends a cons cell to a list, returning the updated list pointer.
struct cons * cons_nth(struct cons *cell, size_t nth)
Returns the n'th cons cell in a linked list of cons cells.
Construct cell structure for building linked lists.
struct cons * cdr
Contents of Decrement Register (CDR).
void * car
Contents of Address Register (CAR).