Merge branch 'master' of https://gitlab.com/sagev9000/pebblisp
This commit is contained in:
commit
130da5a70e
|
@ -189,6 +189,7 @@ struct Environment defaultEnv()
|
|||
{"=", &equ}, {">", >h}, {"<", <h},
|
||||
{"cat", &catObjects}, {"fil", &filter}, {"len", &len}, {"ap", &append},
|
||||
{"at", &at}, {"rest", &rest}, {"rev", &reverse},
|
||||
{"isnum", &isNum},
|
||||
};
|
||||
|
||||
for(unsigned i = 0; i < sizeof(symFuncs)/sizeof(symFuncs[0]); i++) {
|
||||
|
|
|
@ -364,6 +364,12 @@ Object reverse(Object _list, Object ignore, struct Environment *ignore2)
|
|||
return rev;
|
||||
}
|
||||
|
||||
Object isNum(Object test, Object ignore, struct Environment *ignore2)
|
||||
{
|
||||
return test.type == TYPE_NUMBER ?
|
||||
boolObject(1) : boolObject(0);
|
||||
}
|
||||
|
||||
void copySlice(char * dest, struct Slice *src)
|
||||
{
|
||||
if(!dest || !src)
|
||||
|
|
|
@ -54,4 +54,6 @@ Object at(Object index, Object list, struct Environment *env);
|
|||
Object rest(Object list, Object ignore, struct Environment *env);
|
||||
Object reverse(Object _list, Object ignore, struct Environment *ignore2);
|
||||
|
||||
Object isNum(Object test, Object ignore, struct Environment *ignore2);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -86,6 +86,11 @@ check "StringEquality" "(= \"Bean\" \"Bean\" )" "T"
|
|||
check "StringInequality" "(= \"Beans\" \"Bean\" )" "F"
|
||||
endBlock
|
||||
|
||||
title "TypeCheck"
|
||||
check "IsNum" "(isnum 23847123)" "T"
|
||||
check "IsntNum" "(isnum \"WORDS\")" "F"
|
||||
endBlock
|
||||
|
||||
title "Ifs/Bools"
|
||||
check "IfReturn" "(if (T) 123456789 987654321)" "123456789"
|
||||
check "IfRetTwo" "(if F 123456789 987654321)" "987654321"
|
||||
|
|
Loading…
Reference in New Issue