summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-11-06 06:35:34 -0800
committerKaz Kylheku <kaz@kylheku.com>2014-11-06 06:35:34 -0800
commit6cd6af985619569e7e12df7b28c6aa1dc10726c1 (patch)
treef6b64a6bbb70fb630329922a54e470538934876f /lib.c
parent34cb933b006c52eec59dba4478a0d04c8ae4e5ba (diff)
downloadtxr-6cd6af985619569e7e12df7b28c6aa1dc10726c1.tar.gz
txr-6cd6af985619569e7e12df7b28c6aa1dc10726c1.tar.bz2
txr-6cd6af985619569e7e12df7b28c6aa1dc10726c1.zip
Allow then-func to be omitted in iff. Cleanup.
* eval.c (eval_init): Register iff as requiring only one arg. * lib.c (do_iff): Do not check thenfun for nil. Just call it. (iff): Default thenfun to identity. * txr.1: Documentation updated.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib.c b/lib.c
index 4674ff26..6abbf1f1 100644
--- a/lib.c
+++ b/lib.c
@@ -4606,12 +4606,13 @@ static val do_iff(val env, val args)
cons_bind (thenfun, elsefun, choices);
return if3(apply(condfun, args, nil),
- if2(thenfun, apply(thenfun, args, nil)),
+ apply(thenfun, args, nil),
if2(elsefun, apply(elsefun, args, nil)));
}
val iff(val condfun, val thenfun, val elsefun)
{
+ thenfun = default_arg(thenfun, identity_f);
elsefun = default_bool_arg(elsefun);
return func_f0v(cons(condfun, cons(thenfun, elsefun)), do_iff);
}