[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Semantic of pcase `seq' and `map' patterns (was: pcase-setq)
From: |
Nicolas Petton |
Subject: |
Re: Semantic of pcase `seq' and `map' patterns (was: pcase-setq) |
Date: |
Mon, 12 Oct 2015 15:50:51 +0200 |
User-agent: |
Notmuch/0.19 (http://notmuchmail.org) Emacs/25.0.50.7 (x86_64-unknown-linux-gnu) |
Michael Heerdegen <address@hidden> writes:
> After reading the doc of the `seq' pcase pattern:
>
> --8<---------------cut here---------------start------------->8---
> -- (seq &rest ARGS)
>
> pcase pattern matching sequence elements.
> Matches if the object is a sequence (list, string or vector), and
> binds each element of ARGS to the corresponding element of the
> sequence.
> --8<---------------cut here---------------end--------------->8---
>
> it was not obvious to me how this example would look like using pcase -
> especially, what "are" the "ARGS"?
>
> AFAIU the "ARGS" are just normal (pcase) patterns - they are not limited
> to variables, and matching can fail for them as well even if the number
> of sequence arguments would match.
>
> I think the semantic would be better described like this:
>
> --8<---------------cut here---------------start------------->8---
> -- (seq &rest PATTERNS)
>
> pcase pattern matching sequence elements.
> Matches if the object is a sequence (list, string or vector), and
> each PATTERN matches the corresponding element of the
> sequence.
> --8<---------------cut here---------------end--------------->8---
>
> Does that make sense? Likewise `map', I guess.
Yes, it does. You could for example do:
(pcase [1 2 3 4]
...
((seq (pred oddp) (pred evenp)) 'matched)
...)
I will update the documentation, thanks!
Nico
signature.asc
Description: PGP signature
- Re: pcase-setq, (continued)
Re: pcase-setq (was: pcase-dolist), Nicolas Petton, 2015/10/15
- Semantic of pcase `seq' and `map' patterns (was: pcase-setq), Michael Heerdegen, 2015/10/12
- Re: Semantic of pcase `seq' and `map' patterns, Michael Heerdegen, 2015/10/12
- Re: Semantic of pcase `seq' and `map' patterns, Nicolas Petton, 2015/10/12
- Re: Semantic of pcase `seq' and `map' patterns, Michael Heerdegen, 2015/10/12
- Re: Semantic of pcase `seq' and `map' patterns, Michael Heerdegen, 2015/10/17
- Re: Semantic of pcase `seq' and `map' patterns, Nicolas Petton, 2015/10/17
Re: Semantic of pcase `seq' and `map' patterns (was: pcase-setq),
Nicolas Petton <=
Re: pcase-setq, Michael Heerdegen, 2015/10/15