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

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

Quick pcase question


From: Eric Abrahamsen
Subject: Quick pcase question
Date: Wed, 02 Mar 2016 18:12:51 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

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), but have one leftover
question I keep running into.

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.

Thanks,
Eric




reply via email to

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