From d22cb2891030ec2713a8279771f104cf4bebc3bf Mon Sep 17 00:00:00 2001
From: Kaz Kylheku <kaz@kylheku.com>
Date: Tue, 25 May 2021 07:48:47 -0700
Subject: window-map: add tests, improve doc, add examples.

* tests/012/seq.tl: New tests.

* txr.1: Improve documentation of window-map's :wrap
and :reflect. Add examples.
---
 tests/012/seq.tl | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

(limited to 'tests/012/seq.tl')

diff --git a/tests/012/seq.tl b/tests/012/seq.tl
index b38d226f..49d4046b 100644
--- a/tests/012/seq.tl
+++ b/tests/012/seq.tl
@@ -53,3 +53,22 @@
       ((a c b a c b a a b c c b a c b)
        (c b a c b a a b c c b a c b a)
        (b a c b a a b c c b a c b a c)))
+
+(test [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")
+
+(test [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))
+
+(test [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))
-- 
cgit v1.2.3