summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-08-06 20:52:27 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-08-06 20:52:27 -0700
commit586d5d840219a76bd8d36e3b04951e3377709fbd (patch)
tree8260a45eaeb14f7d92ab1ef3430bcb61a9ffd421
parentb7f76edb07c6395e8ae6f3a336292666ea1c8eda (diff)
downloadtxr-586d5d840219a76bd8d36e3b04951e3377709fbd.tar.gz
txr-586d5d840219a76bd8d36e3b04951e3377709fbd.tar.bz2
txr-586d5d840219a76bd8d36e3b04951e3377709fbd.zip
doc: document nested do.
* txr.1: Document do being applied to do/op.
-rw-r--r--txr.155
1 files changed, 55 insertions, 0 deletions
diff --git a/txr.1 b/txr.1
index 13e127ee..7586af51 100644
--- a/txr.1
+++ b/txr.1
@@ -53830,6 +53830,60 @@ from a quasiliteral within a nested
(op ... (op ... `@@@1`))
.brev
+Because the
+.code do
+macro may be applied to operators, it is possible to apply it to itself,
+as well as to
+.codn op ,
+as in the following example:
+
+.verb
+ [[[[(do do do op list) 1] 2] 3] 4] -> (1 2 3 4)
+.brev
+
+The chained application associates right-to-left: the rightmost
+.code do
+is applied to
+.codn op ;
+the second rightmost
+.code do
+is applied to the rightmost on and so on. The effect is that partial
+application has been achieved. The value
+.code 1
+is passed to the resulting function, which returns another function
+which takes the next argument. Finally, all these chained argument
+values are passed to
+.codn list .
+
+Each
+.cod3 do / op
+level is processed independently. The following examples show how the list may
+be permuted into several different orders by referring to an implicit argument
+at various levels of nesting, making it the first argument of
+.codn list .
+The unmentioned arguments implicitly follow, in order. This works because
+mentioning the argument explicitly means that its corresponding
+.code do
+operator no longer inserts its argument implicitly into body of the
+function which it generates:
+
+.verb
+ [[[[(do do do op list @1) 1] 2] 3] 4] -> (4 1 2 3)
+ [[[[(do do do op list @@1) 1] 2] 3] 4] ->(3 1 2 4)
+ [[[[(do do do op list @@@1) 1] 2] 3] 4] -> (2 1 3 4)
+ [[[[(do do do op list @@@@1) 1] 2] 3] 4] -> (1 2 3 4))
+.brev
+
+The following example mentions all arguments at every
+.cod3 do / op
+nesting level, thereby explicitly establishing the order
+in which they are passed to
+.codn list :
+
+.verb
+ [[[[(do do do op list @1 @@1 @@@1 @@@@1) 1] 2] 3] 4] -> (4 3 2 1)
+.brev
+
.TP* Examples:
.verb
@@ -53839,6 +53893,7 @@ from a quasiliteral within a nested
(reduce-left (op + (* 10 @1) @2) '(1 2 3)) --> 123
.brev
+
.coNP Macro @ lop
.synb
.mets (lop << form +)