summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-08-22 11:19:35 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-08-22 11:19:35 -0700
commit1819c8bea0d960f2895485e58901dbcc6193d071 (patch)
treea328d7167e976ae88f8985b2685d7a0a1592d0fd /tests
parent9ec47b693f9618bfd29347226157dc2f8a655ff8 (diff)
downloadtxr-1819c8bea0d960f2895485e58901dbcc6193d071.tar.gz
txr-1819c8bea0d960f2895485e58901dbcc6193d071.tar.bz2
txr-1819c8bea0d960f2895485e58901dbcc6193d071.zip
sub: allow generic iterables.
In this patch we allow the s in (sub s from to) and [s from..to] to be any iterable. * lib.c (iter_dynamic, sub_iter): New static function. (generic_funcall): Handle all objects via the sequence case: ref, sub and all that. Unfortunately, we lose some error handling at the level of the sub function. But we allow any iterable to be passed through to sub. (sub): Handle default case through sub_iter. * tests/012/iter.tl: New cases. * txr.1: Documented.
Diffstat (limited to 'tests')
-rw-r--r--tests/012/iter.tl19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/012/iter.tl b/tests/012/iter.tl
index f98107a5..1151d8ca 100644
--- a/tests/012/iter.tl
+++ b/tests/012/iter.tl
@@ -40,3 +40,22 @@
"DC11" "DC12" "DC13" "DC14" "DC15" "DC16" "DC17" "DC18" "DC19"
"DD01" "DD02" "DD03" "DD04" "DD05" "DD06" "DD07" "DD08" "DD09"
"DD11" "DD12" "DD13" "DD14" "DD15" "DD16" "DD17" "DD18" "DD19"))
+
+(mtest
+ [maprod append "A".."F" (drop 1 "00".."15")]
+ ("A01" "A02" "A03" "A04" "A05" "A10" "A11" "A12" "A13" "A14" "A15"
+ "B01" "B02" "B03" "B04" "B05" "B10" "B11" "B12" "B13" "B14" "B15"
+ "C01" "C02" "C03" "C04" "C05" "C10" "C11" "C12" "C13" "C14" "C15"
+ "D01" "D02" "D03" "D04" "D05" "D10" "D11" "D12" "D13" "D14" "D15"
+ "E01" "E02" "E03" "E04" "E05" "E10" "E11" "E12" "E13" "E14" "E15"
+ "F01" "F02" "F03" "F04" "F05" "F10" "F11" "F12" "F13" "F14" "F15")
+ [maprod append "A".."F" ["00".."99" 1..11]]
+ ("A01" "A02" "A03" "A04" "A05" "A06" "A07" "A08" "A09" "A10" "B01"
+ "B02" "B03" "B04" "B05" "B06" "B07" "B08" "B09" "B10" "C01" "C02"
+ "C03" "C04" "C05" "C06" "C07" "C08" "C09" "C10" "D01" "D02" "D03"
+ "D04" "D05" "D06" "D07" "D08" "D09" "D10" "E01" "E02" "E03" "E04"
+ "E05" "E06" "E07" "E08" "E09" "E10" "F01" "F02" "F03" "F04" "F05"
+ "F06" "F07" "F08" "F09" "F10"))
+
+(test
+ [mapcar identity [0..10 3 6]] (3 4 5))