unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Another pcase-lambda
@ 2017-09-19  0:56 Mark Oteiza
  2017-09-21 11:40 ` Michael Heerdegen
  0 siblings, 1 reply; 11+ messages in thread
From: Mark Oteiza @ 2017-09-19  0:56 UTC (permalink / raw)
  To: emacs-devel; +Cc: Stefan Monnier

Hi,

I wrote the following, as I wanted more out of pcase-lambda.  However,
pcase-lambda already exists so I don't know what to call it.  It does
somewhat emulate SRFI-16's case-lambda.

(defmacro case-lambda (&rest spec)
  "Return an arbitrary arity function."
  (declare (indent 0) (debug (&rest (pcase-QPAT body))))
  (let ((args (make-symbol "args")))
   `(lambda (&rest ,args)
      (pcase-exhaustive ,args ,@spec))))

(case-lambda
  (`() t)
  (`(,x) (cons x 1))
  (`(,x ,y) (list :x x :y y))
  (`(,x ,y . ,z) (vconcat (cons x (cons y z)))))




^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-10-05  3:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-19  0:56 Another pcase-lambda Mark Oteiza
2017-09-21 11:40 ` Michael Heerdegen
2017-09-22 21:37   ` Mark Oteiza
2017-09-22 21:50     ` Clément Pit-Claudel
2017-09-23 14:25     ` Michael Heerdegen
2017-09-23 14:29       ` Stefan Monnier
2017-09-23 15:31         ` Michael Heerdegen
2017-09-28 21:11         ` Ted Zlatanov
2017-10-04 11:03           ` Michael Heerdegen
2017-10-04 16:12             ` Ted Zlatanov
2017-10-05  3:13               ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).