summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-01-24 13:23:51 -0800
committerKaz Kylheku <kaz@kylheku.com>2021-01-24 13:23:51 -0800
commit0a344194aa717aeff7079560ed1624c97066447b (patch)
treea28d6889cb1153f24e19db0d2c8bef38651681f0
parent2a6e91240f8ff72cc340b7910cec23eea0533ccd (diff)
downloadtxr-0a344194aa717aeff7079560ed1624c97066447b.tar.gz
txr-0a344194aa717aeff7079560ed1624c97066447b.tar.bz2
txr-0a344194aa717aeff7079560ed1624c97066447b.zip
doc: add back discussion about (rcons ...) pattern.
* txr.1: Add anote that a pattern a..b matches rcons syntax, and add examples. * tests/011/patmatch.tl: new examples from doc added as tests.
-rw-r--r--tests/011/patmatch.tl3
-rw-r--r--txr.113
2 files changed, 16 insertions, 0 deletions
diff --git a/tests/011/patmatch.tl b/tests/011/patmatch.tl
index ac474738..c9326eda 100644
--- a/tests/011/patmatch.tl
+++ b/tests/011/patmatch.tl
@@ -144,3 +144,6 @@
(test (when-match #R(1 @a) 1..2 a) 2)
(test (when-match #R(2 @a) 1..2 a) nil)
(test (when-match #R(@a 1) 1..2 a) nil)
+
+(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))
diff --git a/txr.1 b/txr.1
index 99e03045..3d64f752 100644
--- a/txr.1
+++ b/txr.1
@@ -39878,6 +39878,12 @@ is matched against its
.code to
part.
+Note that if the range expression notation
+.code a..b
+is used as a pattern, that is actualy a list pattern, due to
+that being a syntactic sugar for
+.codn "(rcons a b)" .
+
.TP* Examples:
.verb
@@ -39886,6 +39892,13 @@ part.
(if-match #R(10 20) #R(1 2) :yes :no) -> :no
(when-match #R(@a @b) 1..2 (list a b)) -> (1 2)
+
+ ;; not a range match! rcons syntax match
+ (when-match @a..@b '1..2 (list a b)) -> (1 2)
+
+ ;; above, de-sugared:
+ (when-match (rcons @a @b) (rcons 1 2) (list a b)) -> (1 2)
+
.brev
.coNP Pattern operator @ struct