以下摘自LetOverlambda
- let over lambda
(let ((counter 0)) (lambda (x) (1+ counter))
- lambda let over lambda
(lambda () (let ((counter 0)) (lambda () (incf counter))))
- let over lambda over let over lambda
(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) (incf counter) (decf counter))))))