[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Replace trivial pcase occurrences in the Emacs sources
From: |
Michael Heerdegen |
Subject: |
Re: Replace trivial pcase occurrences in the Emacs sources |
Date: |
Wed, 31 Oct 2018 21:41:01 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Eli Zaretskii <address@hidden> writes:
> > (pcase '(1 2 3)
> > ((let a 3) a))
> > ==> 3
>
> Thanks, but I meant an example of what's described after the "OTOH".
Oh, sorry. How about this:
(defun second-elt-is-positive-p (l)
(pcase l
(`(,_ ,(pred (< 0)) . ,_) t)))
(second-elt-is-positive-p (list 1 2 3))
==> t
(second-elt-is-positive-p (list 1 -2 3))
==> nil
Is the pattern `(,_ ,(pred (< 0)) . ,_) destructuring or does it
additionally have to bind at least one variable to be called like that?
Such patterns are used in real life - some bind variables, but others
are only used as tests to see if the structure fulfils certain
requirements. I guess there is no sharp dividing line.
Michael.
- Re: Replace trivial pcase occurrences in the Emacs sources, (continued)
- Re: Replace trivial pcase occurrences in the Emacs sources, Eli Zaretskii, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Dmitry Gutov, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Dmitry Gutov, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Eli Zaretskii, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Dmitry Gutov, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Eli Zaretskii, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Michael Heerdegen, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Eli Zaretskii, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Michael Heerdegen, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Eli Zaretskii, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources,
Michael Heerdegen <=
- Re: Replace trivial pcase occurrences in the Emacs sources, Stefan Monnier, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Eli Zaretskii, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Clément Pit-Claudel, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Eli Zaretskii, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Clément Pit-Claudel, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Eli Zaretskii, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Yuri Khan, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Eli Zaretskii, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Dmitry Gutov, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Clément Pit-Claudel, 2018/10/31