diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-01-17 15:06:04 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-01-17 15:06:04 -0800 |
commit | 5d707f9c2b9428ed2b2288912d3f448724c93952 (patch) | |
tree | df7e09ca76a78c540ab7b0cccc3f7ccb28bcf6ec | |
parent | 08239be747be98700d02ff627b49bda0e8f0426a (diff) | |
download | txr-5d707f9c2b9428ed2b2288912d3f448724c93952.tar.gz txr-5d707f9c2b9428ed2b2288912d3f448724c93952.tar.bz2 txr-5d707f9c2b9428ed2b2288912d3f448724c93952.zip |
doc: document @(all)/@(all*) pattern operators.
-rw-r--r-- | txr.1 | 48 |
1 files changed, 48 insertions, 0 deletions
@@ -39964,6 +39964,54 @@ then the match is deemed to have failed. --> :no-match .brev +.coNP Pattern operators @ all and @ all* +.synb +.mets @(all << pattern ) +.mets @(all* << pattern ) +.syne +.desc +The +.code all +and +.code all* +pattern operators require the corresponding object to be a list. +The specified +.meta pattern +is applied against every element of the list. The match is successful if +.meta pattern +matches every element. + +Furthermore, in the case of a successful match, these operators take +each of the variables specified in the +.meta pattern +and bind it to a list of the elements which that variable matched. + +The difference between +.code all +and +.code all* +is as follows. The +.code all +operator respects the vacuous truth of the match when the list is empty. +In that case, the match is successful, and the variables are all bound to +the empty list +.codn nil . +In contrast, the alternative +.code all* +operator behaves like a failed match when the list is empty. + +.TP* Examples: + +.verb + ;; all elements of list match the pattern (x @a @b) + ;; a is bound to (1 2 3); b to (a b c) + + (when-match @(all (x @a @b)) + '((x 1 a) (x 2 b) (x 3 c)) + (list a b)) + --> ((1 2 3) (a b c)) +.brev + .SS* Quasiquote Operator Syntax .coNP Macro @ qquote .synb |