Add explicit (print) function
This commit is contained in:
parent
99fc088d3e
commit
54e2e09c5c
|
@ -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++) {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue