20 extern Cell*
const nil;
28 return new IntCell(i);
37 return new DoubleCell(d);
46 return new SymbolCell(s);
54 inline Cell*
cons(Cell*
const my_car, Cell*
const my_cdr)
56 return new ConsCell(my_car, my_cdr);
63 inline bool nullp(Cell*
const c)
72 inline bool listp(Cell*
const c)
74 return nullp(c) || c->is_cons();
81 inline bool intp(Cell*
const c)
83 return !
nullp(c) && c->is_int();
92 return !
nullp(c) && c->is_double();
101 return !
nullp(c) && c->is_symbol();
119 return c->get_double();
129 return c->get_symbol();
136 inline Cell*
car(Cell*
const c)
145 inline Cell*
cdr(Cell*
const c)
bool listp(Cell *const c)
Check if c points to a list (i.e., nil or a cons cell).
Definition: cons.hpp:72
Cell * make_int(const int i)
Make an int cell.
Definition: cons.hpp:26
Cell * make_double(const double d)
Make a double cell.
Definition: cons.hpp:35
double get_double(Cell *const c)
Accessor (error if c is not a double cell).
Definition: cons.hpp:117
Cell * make_symbol(const char *const s)
Make a symbol cell.
Definition: cons.hpp:44
int get_int(Cell *const c)
Accessor (error if c is not an int cell).
Definition: cons.hpp:108
string get_symbol(Cell *const c)
Retrieve the symbol name as a string (error if c is not a symbol cell).
Definition: cons.hpp:127
bool intp(Cell *const c)
Check if c points to an int cell.
Definition: cons.hpp:81
Cell * cdr(Cell *const c)
Accessor (error if c is not a string cell).
Definition: cons.hpp:145
ostream & operator<<(ostream &os, const Cell &c)
Print the subtree rooted at c, in s-expression notation.
Definition: cons.hpp:155
bool nullp(Cell *const c)
Check if c points to an empty list, i.e., is a null pointer.
Definition: cons.hpp:63
Cell *const nil
The null pointer value.
bool symbolp(Cell *const c)
Check if c points to a symbol cell.
Definition: cons.hpp:99
Cell * cons(Cell *const my_car, Cell *const my_cdr)
Make a conspair cell.
Definition: cons.hpp:54
Cell * car(Cell *const c)
Accessor (error if c is not a cons cell).
Definition: cons.hpp:136
bool doublep(Cell *const c)
Check if c points to a double cell.
Definition: cons.hpp:90