cons.hpp

Go to the documentation of this file.
00001 
00009 #ifndef CONS_HPP
00010 #define CONS_HPP
00011 
00012 #include <iostream>
00013 #include "Cell.hpp"
00014 
00015 using namespace std;
00016 
00021 inline Cell* make_int(const int i)
00022 {
00023   return new Cell(i);
00024 }
00025 
00030 inline Cell* make_double(const double d)
00031 {
00032   return new Cell(d);
00033 }
00034 
00039 inline Cell* make_string(const char* const s)
00040 {
00041   return new Cell(s);
00042 }
00043 
00048 inline Cell* make_symbol(const char* const s)
00049 {
00050   return new Cell(true, s);
00051 }
00052 
00058 inline Cell* cons(Cell* const my_car, Cell* const my_cdr)
00059 {
00060   return new Cell(my_car, my_cdr);
00061 }
00062 
00067 inline bool intp(Cell* const c)
00068 {
00069   return c->is_int();
00070 }
00071 
00076 inline bool doublep(Cell* const c)
00077 {
00078   return c->is_double();
00079 }
00080 
00085 inline bool stringp(Cell* const c)
00086 {
00087   return c->is_string();
00088 }
00089 
00094 inline bool symbolp(Cell* const c)
00095 {
00096   return c->is_symbol();
00097 }
00098 
00103 inline bool listp(Cell* const c)
00104 {
00105   return c->is_cons();
00106 }
00107 
00112 inline int get_int(Cell* const c)
00113 {
00114   return c->get_int();
00115 }
00116 
00121 inline double get_double(Cell* const c)
00122 {
00123   return c->get_double();
00124 }
00125 
00130 inline string get_string(Cell* const c)
00131 {
00132   return c->get_string();
00133 }
00134 
00140 inline string symbol_to_string(Cell* const c)
00141 {
00142   return c->get_symbol();
00143 }
00144 
00149 inline Cell* car(Cell* const c)
00150 {
00151   return c->get_car();
00152 }
00153 
00158 inline Cell* cdr(Cell* const c)
00159 {
00160   return c->get_cdr();
00161 }
00162 
00168 inline ostream& operator<<(ostream& os, const Cell& c)
00169 {
00170   c.print(os);
00171   return os;
00172 }
00173 
00174 #endif // CONS_HPP

Generated on Fri Apr 21 18:12:52 2006 for a1 by  doxygen 1.4.6