diff options
author | Mikael Djurfeldt <djurfeldt@nada.kth.se> | 2000-06-30 16:08:48 +0000 |
---|---|---|
committer | Mikael Djurfeldt <djurfeldt@nada.kth.se> | 2000-06-30 16:08:48 +0000 |
commit | c76b1eafa3d30bae68e03b99c30c41c7e3727148 (patch) | |
tree | c128b074bc7f5a87b5cbd4a17bc4a68229cd4b5e | |
parent | c73879189d82d0a12ebdb077dfaa86e0849fa39f (diff) | |
download | guile-c76b1eafa3d30bae68e03b99c30c41c7e3727148.tar.gz |
* numbers.c (scm_gr_p, scm_leq_p, scm_geq_p): Turned into
primitive generics. (Thanks to Nicolas Neuss.)
-rw-r--r-- | libguile/numbers.c | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/libguile/numbers.c b/libguile/numbers.c index 6d3e808ce..e1e1396db 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -3053,34 +3053,55 @@ scm_less_p (SCM x, SCM y) } -SCM_DEFINE1 (scm_gr_p, ">", scm_tc7_rpsubr, - (SCM x, SCM y), - "Return #t if the list of parameters is monotonically\n" - "increasing.") +SCM_GPROC1 (s_scm_gr_p, ">", scm_tc7_rpsubr, scm_gr_p, g_gr_p); +/* "Return #t if the list of parameters is monotonically\n" + * "increasing." + */ #define FUNC_NAME s_scm_gr_p +SCM +scm_gr_p (SCM x, SCM y) { - return scm_less_p (y, x); + if (!SCM_NUMBERP (x)) + SCM_WTA_DISPATCH_2 (g_gr_p, x, y, SCM_ARG1, FUNC_NAME); + else if (!SCM_NUMBERP (y)) + SCM_WTA_DISPATCH_2 (g_gr_p, x, y, SCM_ARG2, FUNC_NAME); + else + return scm_less_p (y, x); } #undef FUNC_NAME -SCM_DEFINE1 (scm_leq_p, "<=", scm_tc7_rpsubr, - (SCM x, SCM y), - "Return #t if the list of parameters is monotonically\n" - "non-decreasing.") +SCM_GPROC1 (s_scm_leq_p, "<=", scm_tc7_rpsubr, scm_leq_p, g_leq_p); +/* "Return #t if the list of parameters is monotonically\n" + * "non-decreasing." + */ #define FUNC_NAME s_scm_leq_p +SCM +scm_leq_p (SCM x, SCM y) { - return SCM_BOOL_NOT (scm_less_p (y, x)); + if (!SCM_NUMBERP (x)) + SCM_WTA_DISPATCH_2 (g_leq_p, x, y, SCM_ARG1, FUNC_NAME); + else if (!SCM_NUMBERP (y)) + SCM_WTA_DISPATCH_2 (g_leq_p, x, y, SCM_ARG2, FUNC_NAME); + else + return SCM_BOOL_NOT (scm_less_p (y, x)); } #undef FUNC_NAME -SCM_DEFINE1 (scm_geq_p, ">=", scm_tc7_rpsubr, - (SCM x, SCM y), - "Return #t if the list of parameters is monotonically\n" - "non-increasing.") +SCM_GPROC1 (s_scm_geq_p, ">=", scm_tc7_rpsubr, scm_geq_p, g_geq_p); +/* "Return #t if the list of parameters is monotonically\n" + * "non-increasing." + */ #define FUNC_NAME s_scm_geq_p +SCM +scm_geq_p (SCM x, SCM y) { + if (!SCM_NUMBERP (x)) + SCM_WTA_DISPATCH_2 (g_geq_p, x, y, SCM_ARG1, FUNC_NAME); + else if (!SCM_NUMBERP (y)) + SCM_WTA_DISPATCH_2 (g_geq_p, x, y, SCM_ARG2, FUNC_NAME); + else return SCM_BOOL_NOT (scm_less_p (x, y)); } #undef FUNC_NAME |