Add `isstr` to type-checking collection
This commit is contained in:
parent
78f5b98f9f
commit
875228a2b6
|
@ -229,7 +229,7 @@ struct Environment defaultEnv()
|
||||||
{"cat", &catObjects}, {"fil", &filter}, {"len", &len},
|
{"cat", &catObjects}, {"fil", &filter}, {"len", &len},
|
||||||
{"ap", &append}, {"pre", &prepend},
|
{"ap", &append}, {"pre", &prepend},
|
||||||
{"at", &at}, {"rest", &rest}, {"rev", &reverse},
|
{"at", &at}, {"rest", &rest}, {"rev", &reverse},
|
||||||
{"isnum", &isNum},
|
{"isnum", &isNum}, {"isstr", &isString},
|
||||||
{"prn", &print}, {"penv", &printEnvO},
|
{"prn", &print}, {"penv", &printEnvO},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -392,6 +392,12 @@ Object isNum(Object test, Object ignore, struct Environment *ignore2)
|
||||||
boolObject(1) : boolObject(0);
|
boolObject(1) : boolObject(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Object isString(Object test, Object ignore, struct Environment *ignore2)
|
||||||
|
{
|
||||||
|
return test.type == TYPE_STRING ?
|
||||||
|
boolObject(1) : boolObject(0);
|
||||||
|
}
|
||||||
|
|
||||||
Object print(Object p, Object ignore, struct Environment *env)
|
Object print(Object p, Object ignore, struct Environment *env)
|
||||||
{
|
{
|
||||||
p = cloneObject(p);
|
p = cloneObject(p);
|
||||||
|
|
|
@ -56,6 +56,7 @@ Object rest(Object list, Object ignore, struct Environment *env);
|
||||||
Object reverse(Object _list, Object ignore, struct Environment *ignore2);
|
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 isString(Object test, Object ignore, struct Environment *ignore2);
|
||||||
|
|
||||||
Object print(Object p, Object ignore, struct Environment *ignore2);
|
Object print(Object p, Object ignore, struct Environment *ignore2);
|
||||||
Object printEnvO(Object i1, Object i2, struct Environment *env);
|
Object printEnvO(Object i1, Object i2, struct Environment *env);
|
||||||
|
|
Loading…
Reference in New Issue