summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-01-17 23:32:38 -0800
committerKaz Kylheku <kaz@kylheku.com>2021-01-17 23:32:38 -0800
commit4e135a606d57f4fbf4eef1cf67dc7481bc38de97 (patch)
tree1564ac21eb22fda4ab681fe69866e86244761a87
parentdb77030133ed9972314a532c75ea27465a064312 (diff)
downloadtxr-4e135a606d57f4fbf4eef1cf67dc7481bc38de97.tar.gz
txr-4e135a606d57f4fbf4eef1cf67dc7481bc38de97.tar.bz2
txr-4e135a606d57f4fbf4eef1cf67dc7481bc38de97.zip
doc: document @(and)/@(or) pattern operators.
-rw-r--r--txr.155
1 files changed, 55 insertions, 0 deletions
diff --git a/txr.1 b/txr.1
index 95d47627..78dabca8 100644
--- a/txr.1
+++ b/txr.1
@@ -40040,6 +40040,61 @@ Variables are extracted from the first matching which is found.
-> (2 b)
.brev
+.coNP Pattern operators @ and and @ or
+.synb
+.mets @(and << pattern *)
+.mets @(or << pattern *)
+.syne
+.desc
+The
+.code and
+and
+.code or
+operators match multiple patterns in parallel, against
+the same object.
+The
+.code and
+operator matches if every
+.meta pattern
+matches the object, otherwise there is no match.
+The
+.code or
+operator requires one
+.meta pattern
+to match. It tries the patterns in left to right order, and
+stops at the first matching one, declaring failure if none match.
+
+When the
+.code and
+matches, the variables from all of the
+patterns are bound. Duplicate variables from multiple patterns are merged into
+a single instance. The rightmost occurrence of a variable takes precedence; its
+value is the one that appears.
+
+When the
+.code or
+operator matches, the variables from all of the patterns
+are bound.
+The variables from the matching
+.meta pattern
+take on the values implied by that pattern.
+The variables from the non-matching patterns that are not
+duplicates of variables in the matching
+.meta pattern
+take on
+.code nil
+values.
+
+.TP* Examples
+
+.verb
+ (if-match @(and (@x 2 3) (1 @y 3) (1 2 @z)) '(1 2 3)
+ (list x y z)) -> (1 2 3)
+
+ (if-match @(or (@x 3 3) (1 @x 3) (1 2 @x)) '(1 2 3)
+ x) -> 2
+.brev
+
.SS* Quasiquote Operator Syntax
.coNP Macro @ qquote
.synb