Add explicit (print) function

This commit is contained in:
Sage Vaillancourt 2020-10-30 14:36:44 -04:00
parent 99fc088d3e
commit 54e2e09c5c
3 changed files with 12 additions and 0 deletions

View File

@ -196,6 +196,7 @@ struct Environment defaultEnv()
{"ap", &append}, {"pre", &prepend}, {"ap", &append}, {"pre", &prepend},
{"at", &at}, {"rest", &rest}, {"rev", &reverse}, {"at", &at}, {"rest", &rest}, {"rev", &reverse},
{"isnum", &isNum}, {"isnum", &isNum},
{"prn", &print},
}; };
for(unsigned i = 0; i < sizeof(symFuncs)/sizeof(symFuncs[0]); i++) { for(unsigned i = 0; i < sizeof(symFuncs)/sizeof(symFuncs[0]); i++) {

View File

@ -378,6 +378,15 @@ Object isNum(Object test, Object ignore, struct Environment *ignore2)
boolObject(1) : boolObject(0); 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) void copySlice(char * dest, struct Slice *src)
{ {
if(!dest || !src) if(!dest || !src)

View File

@ -57,4 +57,6 @@ Object reverse(Object _list, Object ignore, struct Environment *ignore2);
Object isNum(Object test, Object ignore, struct Environment *ignore2); Object isNum(Object test, Object ignore, struct Environment *ignore2);
Object print(Object p, Object ignore, struct Environment *ignore2);
#endif #endif