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: Thierry Volpiatto
Subject: Re: pcase bindings in patterns with complicated logic
Date: Sun, 14 Jan 2024 17:54:50 +0000

Ihor Radchenko <yantar92@posteo.net> writes:

> 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.

Yes, thanks.

-- 
Thierry

Attachment: signature.asc
Description: PGP signature


reply via email to

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