emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Replace trivial pcase occurrences in the Emacs sources


From: Eli Zaretskii
Subject: Re: Replace trivial pcase occurrences in the Emacs sources
Date: Thu, 01 Nov 2018 06:14:30 +0200

> From: Michael Heerdegen <address@hidden>
> Cc: address@hidden,  address@hidden,  address@hidden
> Date: Wed, 31 Oct 2018 21:41:01 +0100
> 
> (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?

I think we have a destructuring here, since elements of a list are
extracted and assigned to the elements of the pattern.  What we do
with the extracted elements (ignore 2 of them and apply a predicate to
the 3rd) is not really important for the purposes of this discussion.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]