summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-06-05 06:51:32 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-06-05 06:51:32 -0700
commiteca413a144b39299545f7f65b04dfbada4905553 (patch)
treec053f8f8b8ce05d2f717c5278ab3f58b4533b386
parentcdf097ba3d23921a806b103948e0111fca07595e (diff)
downloadtxr-eca413a144b39299545f7f65b04dfbada4905553.tar.gz
txr-eca413a144b39299545f7f65b04dfbada4905553.tar.bz2
txr-eca413a144b39299545f7f65b04dfbada4905553.zip
doc: document each operators using iterables.
* txr.1: The init-forms in (each ...) must be suitable for iter-init and that is now documented. A (range 1 10) in the example is replaced with 1..11.
-rw-r--r--txr.119
1 files changed, 11 insertions, 8 deletions
diff --git a/txr.1 b/txr.1
index 2e29a48d..d5191c34 100644
--- a/txr.1
+++ b/txr.1
@@ -15956,22 +15956,25 @@ is visible.
.syne
.desc
These operators establish a loop for iterating over the elements of one or more
-lists. Each
+sequences. Each
.meta init-form
-must evaluate to a list. The lists are then iterated in
+must evaluate to an iterable object that is suitable as an argument for the
+.code iter-begin
+function.
+The sequences are then iterated in
parallel over repeated evaluations of the
.metn body-form -s,
with each
.meta sym
-variable being assigned to successive elements of its list. The shortest list
-determines the number of iterations, so if any of the
+variable being assigned to successive elements of its sequence. The shortest
+list determines the number of iterations, so if any of the
.metn init-form -s
evaluate to
-an empty list, the body is not executed.
+an empty sequence, the body is not executed.
If the list of
.mono
-.meti >> ( syn << init-form )
+.meti >> ( sym << init-form )
.onom
pairs itself is empty, then an infinite loop is specified.
@@ -16047,9 +16050,9 @@ of their lists.
.TP* Example:
.mono
;; print numbers from 1 to 10 and whether they are even or odd
- (each* ((n (range 1 10)) ;; n list a list here!
+ (each* ((n 1..11) ;; n is just a range object in this scope
(even (collect-each ((m n)) (evenp m))))
- ;; n is an item here!
+ ;; n is an integer in this scope
(format t "~s is ~s\en" n (if even "even" "odd")))
.onom
.TP* Output: