diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2020-06-05 06:51:32 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2020-06-05 06:51:32 -0700 |
commit | eca413a144b39299545f7f65b04dfbada4905553 (patch) | |
tree | c053f8f8b8ce05d2f717c5278ab3f58b4533b386 | |
parent | cdf097ba3d23921a806b103948e0111fca07595e (diff) | |
download | txr-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.1 | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -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: |