Thursday, January 22, 2009

Accumulator Generator in Common Lisp

The following code helps me understand Accumulator Generator in Common Lisp. I am still not used to lisp's true meaning. I often need to struggle to understand a little piece of lisp code. So I write down the code.

(defun foo (n) (lambda (i) (incf n i)))
(setq starting 10)
(setq acc (foo starting))
(funcall acc 1)

For a complete description of Accumulator Generator, refer to Accumulator Generator

No comments: