help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Quick pcase question


From: Phillip Lord
Subject: Re: Quick pcase question
Date: Wed, 02 Mar 2016 12:40:28 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> I'm enjoying pcase quite a bit, particular when employed as a kind of
> improved destructuring-bind. I think I've got the hang of most of it
> (despite the docs being a bit... succinct)

They are being improved! It might be worth looking at the docs in
the Emacs-25 pre-releases.


> What I want to do is: "if this atom matches a predicate, the whole
> pattern matches, and also bind the atom to this local variable."
>
> Right now I'm making that work like this:
>
> (setq tst '(symbolla . "I'm the string"))
>
> (pcase tst
>   (`(symbolla . ,(and x (pred stringp)))
>    (message "cdr is a string: %s" x)))
>
> Is the ",(and x (pred stringp))" part really the simplest way of doing
> that? It just seems a little unintuitive.


I think that's it I am afraid. Don't trust me though, I am no expert.

Phil



reply via email to

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