emacs-devel
[Top][All Lists]
Advanced

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

Re: Question on pcase


From: Michael Heerdegen
Subject: Re: Question on pcase
Date: Fri, 23 Oct 2015 14:23:24 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Hi Oleh,

I guess you might like something like this:

--8<---------------cut here---------------start------------->8---
(defun pcase-demystify-pattern (pattern)
  (pcase--u
   `((,(pcase--match '-tested-expression- (pcase--macroexpand pattern))
      ,(lambda (vars) `(progn ,@(mapcar (lambda (b) `(-bind- ,(car b) ,(cdr b)))
                                   vars)))))))
--8<---------------cut here---------------end--------------->8---

You need to quote the pattern because this is a function.

(pcase-demystify-pattern '`(,_ . ,(and (pred functionp) f)))

  ==>

    (if
        (consp -tested-expression-)
        (let*
            ((#1=#:x
              (cdr -tested-expression-)))
          (if
              (functionp #1#)
              (progn
                (-bind- f #1#))
            nil))
      nil)


Michael.




reply via email to

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