emacs-devel
[Top][All Lists]
Advanced

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

Another pcase-lambda


From: Mark Oteiza
Subject: Another pcase-lambda
Date: Mon, 18 Sep 2017 20:56:37 -0400
User-agent: Mutt/1.9.0 (2017-09-02)

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)))))




reply via email to

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