From 0205a8a433a587e5f1f880b63edbdf169972102c Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20V=C3=A1zquez?= Date: Mon, 6 May 2013 13:50:53 +0100 Subject: [PATCH] Better `case' macro with multikeys --- src/boot.lisp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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) -- 1.7.10.4