diff --git a/lisp/fruit-counter.lisp b/lisp/fruit-counter.lisp index e61d246..d9fb6b8 100644 --- a/lisp/fruit-counter.lisp +++ b/lisp/fruit-counter.lisp @@ -8,20 +8,76 @@ (eval (dlambda - (:inc-apple () (setf apple-count (+ apple-count 1))) - (:dec-apple () (setf apple-count (- apple-count 1))) - (:get-apple () apple-count) - (:set-apple (value) (setf apple-count value)) - (:inc-banana () (setf banana-count (+ banana-count 1))) - (:dec-banana () (setf banana-count (- banana-count 1))) - (:get-banana () banana-count) - (:set-banana (value) (setf banana-count (- banana-count 1))) - (:inc-coconut () (setf coconut-count (+ coconut-count 1))) - (:dec-coconut () (setf coconut-count (- coconut-count 1))) - (:get-coconut () coconut-count) - (:set-coconut (value) (setf coconut-count value)) + + (:inc-apple () + (setf apple-count (+ apple-count 1)) + ) + + (:dec-apple () + (setf apple-count (- apple-count 1)) + ) + + (:get-apple () + apple-count + ) + + (:set-apple (value) + (setf apple-count value) + ) + + (:inc-banana () + (setf banana-count (+ banana-count 1)) + ) + + (:dec-banana () + (setf banana-count (- banana-count 1)) + ) + + (:get-banana () + banana-count + ) + + (:set-banana (value) + (setf banana-count value) + ) + + (:inc-coconut () + (setf coconut-count (+ coconut-count 1)) + ) + + (:dec-coconut () + (setf coconut-count (- coconut-count 1)) + ) + + (:get-coconut () + coconut-count + ) + + (:set-coconut (value) + (setf coconut-count value) + ) + ) ) ) ) + +; Create an instance +; +; usage: +; ~ (my-counter :set-apple 23) +; 23 +; +(let ((instance (fruit-counter 0))) + (defun my-counter (&rest args) (apply instance args)) +) + +; Another way +; +; usage: +; ~ (funcall my-counter2 :set-apple 23) +; 23 +; +(setf my-counter2 (fruit-counter 10000)) + diff --git a/src/function/builtin/special/CASE.java b/src/function/builtin/special/CASE.java index d8fa4ac..fc85b97 100644 --- a/src/function/builtin/special/CASE.java +++ b/src/function/builtin/special/CASE.java @@ -47,7 +47,7 @@ public class CASE extends LispSpecialFunction { else if (keyList.isCons()) return containsMatch(key, keyList); - return isEqual(key, keyList) || isKeyListT(keyList); + return isEqual(key, keyList) || isEqual(T, keyList); } private boolean containsMatch(SExpression key, SExpression keyList) { @@ -58,10 +58,6 @@ public class CASE extends LispSpecialFunction { return false; } - private boolean isKeyListT(SExpression keyList) { - return isEqual(T, keyList); - } - private SExpression advanceCons(SExpression knownCons) { return ((Cons) knownCons).getRest(); }