From 49fee52284fd61c0a0d868314ba5ebeecfb286f1 Mon Sep 17 00:00:00 2001 From: Mike Cifelli Date: Wed, 1 Mar 2017 16:45:48 -0500 Subject: [PATCH] An example class has been added --- lisp/fruit-counter.lisp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 lisp/fruit-counter.lisp diff --git a/lisp/fruit-counter.lisp b/lisp/fruit-counter.lisp new file mode 100644 index 0000000..e61d246 --- /dev/null +++ b/lisp/fruit-counter.lisp @@ -0,0 +1,27 @@ +(load "dlambda.lisp") + +(defun fruit-counter (initial-count) + + (let ((apple-count initial-count) + (banana-count initial-count) + (coconut-count initial-count)) + + (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)) + ) + ) + + ) +)