summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-07-29 20:03:18 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-07-29 20:03:18 -0700
commit187685ec560594fd5e1b26b76c6fea4ec92cc652 (patch)
tree1bf9bc3f4970fac8d7e4536050959075b60a6c7c /eval.c
parentec2bdf886c2970b7b0977bd014cdb7987e7c2dae (diff)
downloadtxr-187685ec560594fd5e1b26b76c6fea4ec92cc652.tar.gz
txr-187685ec560594fd5e1b26b76c6fea4ec92cc652.tar.bz2
txr-187685ec560594fd5e1b26b76c6fea4ec92cc652.zip
* eval.c (repeatv): Renamed to repeat. Turned into function
with one optional argument, reflecting existing behavior. (eval_init): Registration of repeat updated. * txr.1: Fixed incorrect documentation which falsely suggests that repeat takes multiple lists, and doesn't mention the optional count.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/eval.c b/eval.c
index dabb40bf..359c4988 100644
--- a/eval.c
+++ b/eval.c
@@ -3213,15 +3213,15 @@ static val repeat_times_func(val env, val lcons)
return nil;
}
-static val repeatv(val list, val rest)
+static val repeat(val list, val count)
{
if (!list)
return nil;
- if (rest) {
- val count = car(rest);
- if (count == zero)
+
+ if (!missingp(count)) {
+ if (le(count, zero))
return nil;
- return make_lazy_cons(func_f1(cons(list, cons(list, count)),
+ return make_lazy_cons(func_f1(cons(list, cons(list, count)),
repeat_times_func));
}
return make_lazy_cons(func_f1(cons(list, list), repeat_infinite_func));
@@ -3971,7 +3971,7 @@ void eval_init(void)
reg_fun(intern(lit("range*"), user_package), func_n0v(range_star_v));
reg_fun(generate_s, func_n2(generate));
reg_fun(intern(lit("giterate"), user_package), func_n3o(giterate, 2));
- reg_fun(intern(lit("repeat"), user_package), func_n1v(repeatv));
+ reg_fun(intern(lit("repeat"), user_package), func_n2o(repeat, 2));
reg_fun(intern(lit("force"), user_package), func_n1(force));
reg_fun(intern(lit("rperm"), user_package), func_n2(rperm));
reg_fun(intern(lit("perm"), user_package), func_n2o(perm, 1));