diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2023-06-28 22:57:12 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2023-06-28 22:57:12 -0700 |
commit | d7ea45f4c26ff460d062f24f3fbb33c018874dcf (patch) | |
tree | b99849362e2955c4714b09d4a3774d77196317f1 /tests/012/callable.tl | |
parent | 1c583965749a40cdbe15846c2487f32a426dcbeb (diff) | |
download | txr-d7ea45f4c26ff460d062f24f3fbb33c018874dcf.tar.gz txr-d7ea45f4c26ff460d062f24f3fbb33c018874dcf.tar.bz2 txr-d7ea45f4c26ff460d062f24f3fbb33c018874dcf.zip |
New: callable integers and ranges.
* lib.c (do_generic_funcall): Allow integers and ranges
to be function callable. They take one argument and
index into it or extract a slice. In the case of ranges,
this is a breaking change. Ranges can already be used
in the function position in some limited ways that are
not worth preserving.
* tests/012/callable.tl: New file.
* tests/012/iter.tl: Here we fix two instances of
breakage. Using txr -C 288 will restore the
behaviors previously tested here.
* txr.1: Documented.
Diffstat (limited to 'tests/012/callable.tl')
-rw-r--r-- | tests/012/callable.tl | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/012/callable.tl b/tests/012/callable.tl new file mode 100644 index 00000000..0f0e9327 --- /dev/null +++ b/tests/012/callable.tl @@ -0,0 +1,23 @@ +(load "../common") + +(mtest + [0 '(1 2 3)] 1 + [1 '(1 2 3)] 2 + [2 '(1 2 3)] 3) + +(mtest + [0 "abc"] #\a + [1 "abc"] #\b + [2 "abc"] #\c) + +(mtest + [0..1 '(1 2 3)] (1) + [1..3 '(1 2 3)] (2 3)) + +(mtest + [0..0 "abc"] "" + [0..2 "abc"] "ab" + [-1..: "abc"] "c") + +(test (mapcar [callf list* 2 0 1 3..:] '((A B C X) (D E F Y) (G H I Z))) + ((C A B X) (F D E Y) (I G H Z))) |