emacs-devel
[Top][All Lists]
Advanced

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

Re: Question on pcase


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

Michael Heerdegen <address@hidden> writes:

> I guess you might like something like this:
>
> (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)))))))
>
> 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)

Thanks Michael, that's almost exactly what I need. The only thing is
that I don't understand what `-bind-' is.



reply via email to

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