summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-02-05 01:22:58 -0800
committerKaz Kylheku <kaz@kylheku.com>2014-02-05 01:22:58 -0800
commitecefd793e54d3cf0a56df705a18deb587d2a19c1 (patch)
treeaac910f152b09dcd277001a6541e1cd50596b3bf /txr.1
parenta2665d2f02ce417851719f07c9e88bd642d59641 (diff)
downloadtxr-ecefd793e54d3cf0a56df705a18deb587d2a19c1.tar.gz
txr-ecefd793e54d3cf0a56df705a18deb587d2a19c1.tar.bz2
txr-ecefd793e54d3cf0a56df705a18deb587d2a19c1.zip
* eval.c (apply): Pass missing optional arguments as colon_k.
to functions for which this is requested. (reg_fun_mark): New static function. (eval_init): Register reduce_left and reduce_right as requiring marking for missing optionals. * lib.c (func_set_mark_missing): New function. (generic_funcall): Pass missing optional arguments as colon_k to functions for which this is requested. (reduce_left, reduce_right): Handle missing values of init and key. (func_f0, func_f1, func_f2, func_f3, func_f4, func_n0, func_n1, func_n2, func_n3, func_n4, func_n5, func_n6, func_n7, func_f0v, func_f1v, func_f2v, func_f3v, func_f4v, func_n0v, func_n1v, func_n2v, func_n3v, func_n4v, func_n5v, func_n6v, func_n7v): Initialize new mark_missing_args member of struct func. * lib.h (struct func): New bitfield member, mark_missing_args. (func_set_mark_missing): Declared. (missingp, null_or_missing_p): New inline functions. * txr.1: Updated descriptions of reduce-left and reduce-right.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.122
1 files changed, 14 insertions, 8 deletions
diff --git a/txr.1 b/txr.1
index bb2325a5..dc88581e 100644
--- a/txr.1
+++ b/txr.1
@@ -7247,18 +7247,17 @@ by <list> and <init-value> to a single value by the repeated application of
<binary-function>.
An effective list of operands is formed by combining <list> and
-<init-value>. If <key-function> is specified and not nil, then
-the items of <list> are mapped to a new values through <key-function>.
-If an <init-value> is supplied and not nil, then in the
-case of reduce-left, the effective list of operands is formed by prepending
-<init-value> to <lits>. In the case of reduce-right, the effective
+<init-value>. If <key-function> is specified, then the items of <list> are
+mapped to a new values through <key-function>. If <init-value> is supplied,
+then in the case of reduce-left, the effective list of operands is formed by
+prepending <init-value> to <lits>. In the case of reduce-right, the effective
operand list is produced by appending <init-value> to <list>.
The production of the effective list can be expressed like this,
-though this is not to be understood as the actual impelmentation:
+though this is not to be understood as the actual implementation:
;; reduce-left
- (let ((eff-list (append (if init-value (list init-value))
+ (let ((eff-list (append (if init-value-present (list init-value))
[mapcar (or key-function identity) list])))
In the reduce-right case, the arguments to append are reversed.
@@ -7273,6 +7272,13 @@ If the effective list contains one item, then that item is returned.
Otherwise, the effective list contains two or more items, and is decimated as
follows.
+Note that an <init-value> specified as nil is not the same as a missing
+<init-value>; this means that the initial value is the object nil. Omitting
+<init-value> is the same as specifying a value of : (the colon symbol).
+It is possible to specify <key-function> while omitting an <init-value>
+argument. This is achieved by explicitly specifying : as the <init-value>
+argument.
+
Under reduce-left, the leftmost pair of operands is removed
from the list and passed as arguments to <binary-function>, in the same order
that they appear in the list, and the resulting value initializes an
@@ -7282,7 +7288,7 @@ from the list. After each call, the accumulator is updated with the return
value of <binary-function>. The final value of the accumulator is returned.
Under reduce-right, the list is processed right to left. The rightmost
-pair of elements in the effetive list is removed, and passed as arguments to
+pair of elements in the effective list is removed, and passed as arguments to
<binary-function>, in the same order that they appear in the list. The
resulting value initializes an accumulator. Then, for each remaining item in
the list, <binary-function> is invoked on two arguments: the