|
cons
|
Inspired by Lisp, "Cons" is a lightweight C99 library that provides a clean, efficient implementation of singly-linked lists. Designed for simplicity and performance, it offers essential operations for managing dynamic collections of data in C programs without the overhead of other dependencies.
cons, cons_car, and cons_cdrTo use the Cons library, include the header file and link against the compiled library in your C project. The API provides functions for constructing and manipulating lists, as well as traversing and modifying hierarchical node structures.
What does this code do? It constructs two cons cells, cell1 and cell2, with values 1 and 2 respectively. It then constructs a list by prepending these cells to the head pointer, resulting in a list that contains both cells.