summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
Diffstat (limited to 'txr.1')
-rw-r--r--txr.187
1 files changed, 64 insertions, 23 deletions
diff --git a/txr.1 b/txr.1
index e36c220c..65e52bce 100644
--- a/txr.1
+++ b/txr.1
@@ -33913,43 +33913,84 @@ flanking elements obtained from
If
.meta boundary
-is the keyword
+argument is specified as the keyword
.codn :wrap ,
-then the sequence is effectively flanked by copies of itself on both
-ends, repeated enough times to satisfy the window. For instance if
-the sequence is
+then the sequence is imagined to be flanked at either end by an infinite
+repetition of copies of itself. These flanks are trimmed to the window size to
+generate the boundary.
+
+For instance if the sequence is
.code "(1 2 3)"
and the window size is 9 due to the value of
.meta range
-being 7, then the behavior of
+being 4, then the behavior of
.code :wrap
-is as if a
+is as if
.meta boundary
-were specified consisting of
-.codn "(3 1 2 3 1 2 3 1)" .
+value of
+.code "(3 1 2 3 1 2 3 1)"
+were specified.
The left flank is
-.code "(3 1 2 3)"
-and the right flank is
-.code "(1 2 3 4)"
-formed by repetitions of
-.code "(1 2 3)"
-surrounding it on either side, extending out to infinity, and chopped to
-.metn range .
+.codn "(3 1 2 3)" ,
+being the last four elements of an infinite repetition of
+.codn "1 2 3" ;
+and the right flank is similarly
+.codn "(1 2 3 1)" ,
+being the first four elements of an infinite repetition of
+.codn "1 2 3" .
If
.meta boundary
-is the keyword
+is given as the keyword
.codn :reflect ,
-then the sequence is effectively flanked by reversed copies of itself
-on both ends, repeated enough times to satisfy the window.
-For instance if the sequence is
+then the sequence is imagined to be flanked at either end by an infinite
+repetition of reversed copies of itself. These flanks are trimmed to the window
+size to generate the boundary. For instance if the sequence is
.code "(1 2 3)"
-and the window size is 9, then the behavior of
+and the window size is 9 due to the value of
+.meta range
+being 4, then the behavior of
.code :reflect
-is as if a
+is as if
.meta boundary
-were specified consisting of
-.codn "(1 3 2 1 3 2 1 3)" .
+value of
+.code "(1 3 2 1 3 2 1 3)"
+were specified.
+The left flank is
+.codn "(1 3 2 1)" ,
+being the last four elements of an infinite repetition of
+.codn "3 2 1" ;
+and the right flank is similarly
+.codn "(3 2 1 3)" ,
+being the first four elements of an infinite repetition of
+.codn "3 2 1" .
+
+.TP* Examples:
+.verb
+ ;; change characters between angle brackets to upper case.
+ [window-map 1 nil (lambda (x y z)
+ (if (and (eq x #\<)
+ (eq z #\>))
+ (chr-toupper y)
+ y))
+ "ab<c>de<f>g"]
+ --> "ab<C>de<F>g"
+
+ ;; collect all numbers which are the centre element of
+ ;; a monotonically increasing triplet
+ [window-mappend 1 :reflect (lambda (x y z)
+ (if (< x y z)
+ (list y)))
+ '(1 2 1 3 4 2 1 9 7 5 7 8 5)]
+ --> (3 7)
+
+ ;; calculate a moving average with a five-element
+ ;; window, flanked by zeros at the boundaries:
+ [window-map 2 #(0 0 0 0)
+ (lambda (. args) (/ (sum args) 5))
+ #(4 7 9 13 5 1 6 11 10 3 8)]
+ --> #(4.0 6.6 7.6 7.0 6.8 7.2 6.6 6.2 7.6 6.4 4.2))
+.brev
.coNP Function @ interpose
.synb