diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-01-26 00:46:57 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-01-26 00:46:57 -0800 |
commit | deae97f0dfdf0ea33bba2912f05bb6b350553b94 (patch) | |
tree | 7d7a344efe14c3c5acb861870d07d71038f1face /tests/011 | |
parent | 030f25146ff5d2f6671ef1b615fc4217004632e5 (diff) | |
download | txr-deae97f0dfdf0ea33bba2912f05bb6b350553b94.tar.gz txr-deae97f0dfdf0ea33bba2912f05bb6b350553b94.tar.bz2 txr-deae97f0dfdf0ea33bba2912f05bb6b350553b94.zip |
matcher: allow pat/var argument: @[expr var pat]
* share/txr/stdlib/match.tl (compile-dwim-predicate-match):
Drop redundant bindable check of sym, since compile-var-match
checks this. Support third argument which gives a pattern or
variable which captures the value from the predicate function,
which might be interesting (not just true/false).
* tests/011/patmatch.tl: New tests.
* txr.1: Documented.
Diffstat (limited to 'tests/011')
-rw-r--r-- | tests/011/patmatch.tl | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/011/patmatch.tl b/tests/011/patmatch.tl index c9326eda..784588ad 100644 --- a/tests/011/patmatch.tl +++ b/tests/011/patmatch.tl @@ -147,3 +147,11 @@ (test (when-match @a..@b '1..2 (list a b)) (1 2)) (test (when-match (rcons @a @b) '(rcons 1 2) (list a b)) (1 2)) + +(test (let ((h #H(() (a 1) (b 2)))) + (when-match @[h x y] 'a (list x y))) + (a 1)) + +(test (let ((h #H(() (a 1) (b 2)))) + (when-match @[h x @(oddp y)] 'a (list x y))) + (a 1)) |