summaryrefslogtreecommitdiffstats
path: root/txr.1
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 /txr.1
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 'txr.1')
-rw-r--r--txr.153
1 files changed, 37 insertions, 16 deletions
diff --git a/txr.1 b/txr.1
index 165848b1..2ca3a0a1 100644
--- a/txr.1
+++ b/txr.1
@@ -20628,7 +20628,7 @@ and then inverts the result as if by application of the
.coNP Functions @ iff and @ iffi
.synb
-.mets (iff < cond-func < then-func <> [ else-func ])
+.mets (iff < cond-func >> [ then-func <> [ else-func ]])
.mets (iffi < cond-func < then-func <> [ else-func ])
.syne
.desc
@@ -20639,7 +20639,7 @@ function is the functional equivalent of the
operator. It accepts
functional arguments and returns a function.
-The resulting function takes its arguments and applies them to
+The resulting function takes its arguments, if any, and applies them to
.metn cond-func .
If
.meta cond-func
@@ -20651,6 +20651,15 @@ resulting value is returned. Otherwise the arguments are passed to
and the resulting value is returned.
If
+.meta then-func
+is omitted then
+.code identity
+is used as default. This omission is not permitted by
+.codn iffi ,
+only
+.codn iff .
+
+If
.meta else-func
needs to be called, but is omitted, then
.code nil
@@ -20663,26 +20672,38 @@ function differs from
only in the defaulting behavior with respect
to the
.meta else-func
-argument. The following equivalences hold:
+argument. If
+.meta else-func
+is omitted in a call to
+.code iffi
+then the deafult function is
+.codn identity .
+This is useful in situations when one value is to be
+replaced with another one when the condition is true, otherwise
+preserved.
+
+The following equivalences hold between
+.code iffi
+and
+.codn iff :
.cblk
- (iffi a b c) <--> (iff a b c)
+ (iffi a b c) <--> (iff a b c)
- (iffi a b) <--> (iff a b identity)
+ (iffi a b) <--> (iff a b identity)
- (iffi a b nil) <--> (iff a b identity)
+ (iffi a b false) <--> (iff a b)
+
+ (iffi a identity false) <--> (iff a)
.cble
-The
-.code iffi
-function defaults to the identity function when
-.meta else-func
-is
-omitted or
-.codn nil ,
-and therefore is useful in situations when one value is to be
-replaced with another one when the condition is true, otherwise
-preserved.
+The following equivalence illustrates
+.code iff
+with both optional arguments omitted:
+
+.cblk
+ (iff a) <---> (iff a identity false)
+.cble
.coNP Functions @ tf and @ nilf
.synb