diff --git a/src/env.c b/src/env.c index 5ed0f35..1dc2b10 100644 --- a/src/env.c +++ b/src/env.c @@ -196,6 +196,7 @@ struct Environment defaultEnv() {"ap", &append}, {"pre", &prepend}, {"at", &at}, {"rest", &rest}, {"rev", &reverse}, {"isnum", &isNum}, + {"prn", &print}, }; for(unsigned i = 0; i < sizeof(symFuncs)/sizeof(symFuncs[0]); i++) { diff --git a/src/pebblisp.c b/src/pebblisp.c index d0789a3..d65e74c 100644 --- a/src/pebblisp.c +++ b/src/pebblisp.c @@ -378,6 +378,15 @@ Object isNum(Object test, Object ignore, struct Environment *ignore2) boolObject(1) : boolObject(0); } +Object print(Object p, Object ignore, struct Environment *env) +{ + p = cloneObject(p); + p = eval(&p, env); + printObj(&p); + printf("\n"); + return p; +} + void copySlice(char * dest, struct Slice *src) { if(!dest || !src) diff --git a/src/pebblisp.h b/src/pebblisp.h index 556bb80..7fc33b5 100644 --- a/src/pebblisp.h +++ b/src/pebblisp.h @@ -57,4 +57,6 @@ Object reverse(Object _list, Object ignore, struct Environment *ignore2); Object isNum(Object test, Object ignore, struct Environment *ignore2); +Object print(Object p, Object ignore, struct Environment *ignore2); + #endif