From: David Vázquez Date: Mon, 6 May 2013 12:50:53 +0000 (+0100) Subject: Better `case' macro with multikeys X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=0205a8a433a587e5f1f880b63edbdf169972102c;p=jscl.git Better `case' macro with multikeys --- diff --git a/src/boot.lisp b/src/boot.lisp index 0b58676..c9e47df 100644 --- a/src/boot.lisp +++ b/src/boot.lisp @@ -185,11 +185,13 @@ `(let ((,!form ,form)) (cond ,@(mapcar (lambda (clausule) - (if (or (eq (car clausule) t) - (eq (car clausule) 'otherwise)) - `(t ,@(cdr clausule)) - `((eql ,!form ',(car clausule)) - ,@(cdr clausule)))) + (destructuring-bind (keys &body body) + clausule + (if (or (eq keys 't) (eq keys 'otherwise)) + `(t nil ,@body) + (let ((keys (if (listp keys) keys (list keys)))) + `((or ,@(mapcar (lambda (key) `(eql ,!form ',key)) keys)) + nil ,@body))))) clausules))))) (defmacro ecase (form &rest clausules)