cons
Loading...
Searching...
No Matches
cons_node.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: MIT */
2
11#ifndef CONS_NODE_H
12#define CONS_NODE_H
13
14#include "cons.h"
15
22#define CONS_NODE(_cell_, _head_) ((struct cons_node){.cell = (_cell_), .head = (_head_)})
23
32#define CONS_NODE_NULL CONS_NODE(CONS(NULL, CONS_NIL), CONS_NIL)
33
44struct cons_node {
55 struct cons cell;
56
62 struct cons *head;
63};
64
71struct cons_node *cons_car_node(struct cons_node *node);
72
82struct cons_node *cons_cdr_node(struct cons_node *node);
83
92struct cons_node *cons_sub_node(struct cons_node *node);
93
100struct cons_node *cons_node(struct cons_node *sub, struct cons_node *super);
101
102#endif /* CONS_NODE_H */
A simple implementation of cons cells for building linked lists.
struct cons_node * cons_car_node(struct cons_node *node)
Accessor for the parent node (super-node) of a cons node.
Definition cons_node.c:36
struct cons_node * cons_cdr_node(struct cons_node *node)
Accessor for the next sibling node of a cons node.
Definition cons_node.c:38
struct cons_node * cons_sub_node(struct cons_node *node)
Accessor for the first child node (sub-node) of a cons node.
Definition cons_node.c:40
Structure representing a cons node.
Definition cons_node.h:44
struct cons * head
Pointer to the list of child nodes (sub-nodes).
Definition cons_node.h:62
struct cons cell
The cons cell forming the basis of the node.
Definition cons_node.h:55
Construct cell structure for building linked lists.
Definition cons.h:73