summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-10-16 19:01:26 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-10-16 19:01:26 -0700
commit499f04dc4f9f864071d6ff7e75c9cbec60e2fd12 (patch)
treea088c450568622b02c46dbce6cec053861c04569 /eval.c
parentb2dfc50f1c98417166d647538d7d5ecd6178dd4c (diff)
downloadtxr-499f04dc4f9f864071d6ff7e75c9cbec60e2fd12.tar.gz
txr-499f04dc4f9f864071d6ff7e75c9cbec60e2fd12.tar.bz2
txr-499f04dc4f9f864071d6ff7e75c9cbec60e2fd12.zip
* arith.c (gcd): Fix semantics. If either operand is
zero, return the other operand. (lcm): New function. * eval.c (eval_init): Retarget registration of gcd to variable argument gcdv function. Register lcm. * lib.c (gcdv, lcmv): New functions. * lib.h (gcdv, lcm, lcmv): Declared. * txr.1: Re-document gcd with coverage of lcm. * txr.vim: Regenerated.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/eval.c b/eval.c
index 753d0211..5a5e7baf 100644
--- a/eval.c
+++ b/eval.c
@@ -3605,7 +3605,8 @@ void eval_init(void)
reg_fun(intern(lit("expt"), user_package), func_n0v(exptv));
reg_fun(intern(lit("exptmod"), user_package), func_n3(exptmod));
reg_fun(intern(lit("isqrt"), user_package), func_n1(isqrt));
- reg_fun(intern(lit("gcd"), user_package), func_n2(gcd));
+ reg_fun(intern(lit("gcd"), user_package), func_n0v(gcdv));
+ reg_fun(intern(lit("lcm"), user_package), func_n0v(lcmv));
reg_fun(intern(lit("floor"), user_package), func_n1(floorf));
reg_fun(intern(lit("ceil"), user_package), func_n1(ceili));
reg_fun(intern(lit("sin"), user_package), func_n1(sine));