diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-02-12 19:56:21 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-02-12 19:56:21 -0800 |
commit | 7ed3b0ad7626612aa4b0420dd3dcfdbf5b168fb8 (patch) | |
tree | e25352c7596f0ace73a574f2399d5a8ebebe44df /txr.1 | |
parent | 00931fee52a70cf445a63e273851b9b973a70a58 (diff) | |
download | txr-7ed3b0ad7626612aa4b0420dd3dcfdbf5b168fb8.tar.gz txr-7ed3b0ad7626612aa4b0420dd3dcfdbf5b168fb8.tar.bz2 txr-7ed3b0ad7626612aa4b0420dd3dcfdbf5b168fb8.zip |
New functions pad and weave.
* eval.c (pad_func, pad, weave_while, weave_gen, weavev):
New static functions.
(eval_init): Registered pad and weave intrisics.
* txr.1: Documented pad and weave.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 61 |
1 files changed, 61 insertions, 0 deletions
@@ -15294,6 +15294,67 @@ repetitions of .meta list catenated together. +.coNP Function @ pad +.synb +.mets (pad < sequence < object <> [ count ]) +.syne +.desc +The +.code pad +function produces a lazy list which consists of all of the +elements of +.meta sequence +followed by repetitions of +.meta object . + +If +.meta count +is omitted, then the repetition of +.meta object +is infinite. Otherwise the specified number of repetitions +occur. + +Note that +.meta sequence +may be a lazy list which is infinite. In that case, the repetitions +of +.meta object +will never occur. + +.coNP Function @ weave +.synb +.mets (weave >> { sequence }*) +.syne +The +.code weave +function interleaves elements from the sequences given as arguments. + +If called with no arguments, it returns the empty list. + +If called with a single sequence, it returns the elements of that sequence +as a new lazy list. + +When called with two or more sequences, +.code +weave +returns a lazy list which draws elements from the sequeces in a round-robin +fashion, repeatedly scanning the sequences from left to right, and +taking an item from each one, removing it from the sequence. +Whenever a sequence runs out of items, it is deleted; the weaving then +continues with the remaining sequences. The weaved sequence terminates +when all sequences are eliminated. (If at least one of the sequences +is an infinite lazy list, then the weaved sequence is infinite.) + +.TP* Examples: + +.cblk + ;; Weave negative integers with positive ones: + (weave (range 1) (range -1 : -1)) -> (1 -1 2 -2 3 -3 ...) + + (weave "abcd" (range 1 3) '(x x x x x x x)) + --> (#\ea 1 x #\eb 2 x #\ec 3 x #\ed x x x x) +.cble + .coNP Macros @ gen and @ gun .synb .mets (gen < while-expression << produce-item-expression ) |