emacs-devel
[Top][All Lists]
Advanced

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

Re: pcase bindings in patterns with complicated logic


From: Ihor Radchenko
Subject: Re: pcase bindings in patterns with complicated logic
Date: Sun, 14 Jan 2024 16:21:44 +0000

Thierry Volpiatto <thievol@posteo.net> writes:

>>> [ BTW I don't understand why `app` pattern exists as long as now `pred` is
>>> supporting an extra arg ]
>>
>> Isn't it explained right in the manual?
>>
>> ‘(app FUNCTION PATTERN)’
>>      Matches if FUNCTION called on EXPVAL returns a value that matches
>>      PATTERN.  FUNCTION can take one of the forms described for ‘pred’,
>>      above.  Unlike ‘pred’, however, ‘app’ tests the result against
>>      PATTERN, rather than against a boolean truth value.
>
> Perhaps it is right but I don't understand it, an example in the manual
> would be welcome (if there is one I missed it).

Does this example help?

(pcase '(1 2 3)
  ((app cdr `(2 ,c)) (format "Match: %S" c)))

You cannot easily do the same with pred.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



reply via email to

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