transcendental-lisp/lisp/object/static.lisp

16 lines
409 B
Common Lisp
Raw Normal View History

2017-03-08 11:14:44 -05:00
;; This is based on an example presented in "Let Over Lambda" by Doug Hoyte.
(let ((direction 'up))
(defun toggle-counter-direction ()
(setq direction
(if (eq direction 'up)
'down
'up)))
(defun counter-class ()
(let ((counter 0))
(lambda ()
(if (eq direction 'up)
(setq counter (+ counter 1))
(setq counter (- counter 1)))))))