summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-01-25 16:35:34 -0800
committerKaz Kylheku <kaz@kylheku.com>2015-01-25 16:35:34 -0800
commit0515d6ee6af5f16a951f7dd61ddc3f3e2cd0e562 (patch)
tree0dd6c287ca0eef9646446fa7e65d5532a4ff826b /txr.1
parent4ec024cdc9544c244cbd8b630e8f631fc05c6075 (diff)
downloadtxr-0515d6ee6af5f16a951f7dd61ddc3f3e2cd0e562.tar.gz
txr-0515d6ee6af5f16a951f7dd61ddc3f3e2cd0e562.tar.bz2
txr-0515d6ee6af5f16a951f7dd61ddc3f3e2cd0e562.zip
* eval.c (call_f): new global variable.
(do_mapf, mapf): new static functions. (eval_init): protect call_f from gc, and initialize it. re-register call function using call_f. register mapf intrinsic. * txr.1: Documented mapf.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.145
1 files changed, 45 insertions, 0 deletions
diff --git a/txr.1 b/txr.1
index 29e9fa7b..668a12c9 100644
--- a/txr.1
+++ b/txr.1
@@ -21477,6 +21477,51 @@ arguments:
-> ((1 1) (4 4))
.cble
+.coNP Function @ mapf
+.synb
+.mets (mapf < main-function << arg-function *)
+.syne
+.desc
+The
+.code mapf
+function returns a function which distributes its arguments
+into the
+.metn arg-function -s.
+That is to say, each successive argument of the returned
+function is associated with a successive
+.metn arg-function .
+
+Each
+.metn arg-function
+is called, passed the corresponding argument. The return
+values of these functions are then passd as arguments
+to
+.meta main function
+and the resulting value is returned.
+
+If the returned function is calle with fewer arguments than there
+are
+.metn arg-function -s,
+then only that many functions are used. Conversely, if the function is
+called with more arguments than there are
+.metn arg-function -s, then those arguments are ignored.
+
+The following equivalence holds:
+
+.cblk
+ (mapf fm f0 f1 ...) <--> (lambda (. rest)
+ [apply fm [mapcar call (list f0 f1 ...) rest]])
+.cble
+
+.TP* Example:
+
+.cblk
+ ;; Keep those pairs which are two of a kind
+
+ (keep-if [callf eql first second] '((1 1) (2 3) (4 4) (5 6)))
+ -> ((1 1) (4 4))
+.cble
+
.SS* Input and Output (Streams)
\*(TL supports input and output streams of various kinds, with
generic operations that work across the stream types.