diff options
author | Teddy <[email protected]> | 2013-08-09 20:28:37 +0800 |
---|---|---|
committer | Teddy <[email protected]> | 2013-08-09 20:28:37 +0800 |
commit | ed541c0d83caff9e417a89bc4e6ae83ea22eb214 (patch) | |
tree | 3c8998067286bf966fa8de1ce9e19669daf8a2fd | |
parent | db59e90e97adaacf758bbd5f4cd86ed9b30262d6 (diff) |
bugfix on `lt` `gt` `eq`, added `number?`
-rw-r--r-- | builtin.cpp | 8 | ||||
-rw-r--r-- | builtin.h | 1 | ||||
-rw-r--r-- | eval.cpp | 1 |
3 files changed, 10 insertions, 0 deletions
diff --git a/builtin.cpp b/builtin.cpp index 94fcd9b..a8091ba 100644 --- a/builtin.cpp +++ b/builtin.cpp @@ -1028,6 +1028,7 @@ BUILTIN_PROC_DEF(num_lt) { throw TokenError("a number", RUN_ERR_WRONG_TYPE); NumObj *last = static_cast<NumObj*>(args->car), *opr; + args = TO_PAIR(args->cdr); for (; args != empty_list; args = TO_PAIR(args->cdr), last = opr) { if (!args->car->is_num_obj()) // not a number @@ -1052,6 +1053,7 @@ BUILTIN_PROC_DEF(num_gt) { throw TokenError("a number", RUN_ERR_WRONG_TYPE); NumObj *last = static_cast<NumObj*>(args->car), *opr; + args = TO_PAIR(args->cdr); for (; args != empty_list; args = TO_PAIR(args->cdr), last = opr) { if (!args->car->is_num_obj()) // not a number @@ -1076,6 +1078,7 @@ BUILTIN_PROC_DEF(num_eq) { throw TokenError("a number", RUN_ERR_WRONG_TYPE); NumObj *last = static_cast<NumObj*>(args->car), *opr; + args = TO_PAIR(args->cdr); for (; args != empty_list; args = TO_PAIR(args->cdr), last = opr) { if (!args->car->is_num_obj()) // not a number @@ -1417,6 +1420,11 @@ do { \ return new BoolObj(true); } +BUILTIN_PROC_DEF(is_number) { + ARGS_EXACTLY_ONE; + return new BoolObj(args->car->is_num_obj()); +} + BUILTIN_PROC_DEF(display) { ARGS_EXACTLY_ONE; printf("%s\n", args->car->ext_repr().c_str()); @@ -262,6 +262,7 @@ BUILTIN_PROC_DEF(num_eq); BUILTIN_PROC_DEF(num_is_exact); BUILTIN_PROC_DEF(num_is_inexact); +BUILTIN_PROC_DEF(is_number); BUILTIN_PROC_DEF(bool_not); BUILTIN_PROC_DEF(is_boolean); @@ -34,6 +34,7 @@ void Evaluator::add_builtin_routines() { ADD_BUILTIN_PROC("exact?", num_is_exact); ADD_BUILTIN_PROC("inexact?", num_is_inexact); + ADD_BUILTIN_PROC("number?", is_number); ADD_BUILTIN_PROC("not", bool_not); ADD_BUILTIN_PROC("boolean?", is_boolean); |