[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: pcase bindings in patterns with complicated logic
From: |
Richard Stallman |
Subject: |
Re: pcase bindings in patterns with complicated logic |
Date: |
Sat, 20 Jan 2024 22:06:46 -0500 |
[[[ To any NSA and FBI agents reading my email: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
> (pcase '((foo . 1) (bar . 2) (baz . 3))
> ((and `((foo . 1) . ,_)
> (app (mapcar #'cdr) `(,_ ,_ ,c)))
> (format "Match: %S" c)))
> The above matches `((foo . 1) . ,_) against '((foo . 1) (bar . 2) (baz . 3))
> and then matches `(,_ ,_ ,c) against a different value - '(1 2 3)
One of the basic benefits of cond* is that you're not compelled to match
all the patterns against the same data object.
I am not confident I understand app pattern, but if it does what I now
think, the equivalent of (app (mapcar #'cdr) `(,_ ,_ ,c))) would be
this:
(match* `(,_ ,_ ,c) (mapcar 'car '((foo . 1) (bar . 2) (baz . 3))))
What cond* cannot do is apply `and' to two different match* clauses
which test different objects. I could add that capability. I could
also add `app', if that is worth adding. Its absence is not a fundamental
design issue, just that it dud not seem necessary.
That example wan't a solution to a real problem, so I am not convinced
this is a real gap in cond*. If I see this sort of situation in a
real problem, that will convince me I should do something about this.
Thanks for helping me understand this issue.
--
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)
- Re: pcase bindings in patterns with complicated logic, (continued)
- Re: pcase bindings in patterns with complicated logic, Ihor Radchenko, 2024/01/14
- Re: pcase bindings in patterns with complicated logic, Thierry Volpiatto, 2024/01/14
- Re: pcase bindings in patterns with complicated logic, Ihor Radchenko, 2024/01/14
- Re: pcase bindings in patterns with complicated logic, Thierry Volpiatto, 2024/01/14
- Re: pcase bindings in patterns with complicated logic, Richard Stallman, 2024/01/15
- Re: pcase bindings in patterns with complicated logic, Ihor Radchenko, 2024/01/16
- Re: pcase bindings in patterns with complicated logic, Richard Stallman, 2024/01/17
- Re: pcase bindings in patterns with complicated logic, Ihor Radchenko, 2024/01/18
- Re: pcase bindings in patterns with complicated logic, Richard Stallman, 2024/01/19
- Re: pcase bindings in patterns with complicated logic, Ihor Radchenko, 2024/01/20
- Re: pcase bindings in patterns with complicated logic,
Richard Stallman <=
- Re: pcase bindings in patterns with complicated logic, Ihor Radchenko, 2024/01/21
- Re: pcase bindings in patterns with complicated logic, Richard Stallman, 2024/01/23
- Re: pcase bindings in patterns with complicated logic, Stefan Monnier, 2024/01/23
- Re: pcase bindings in patterns with complicated logic, Stefan Monnier, 2024/01/23
Re: pcase bindings in patterns with complicated logic, Richard Stallman, 2024/01/14
Re: pcase bindings in patterns with complicated logic, Thierry Volpiatto, 2024/01/14