Closures that Share Bindings
> (defun make-stack ()
(let ((stack nil))
(cons
#'(lambda (item) ; closure for push.
(setq stack (cons item stack)) )
#'(lambda () ; closure for pop.
(if stack
(progn
(let ((top (first stack)))
(setq stack (rest stack))
top) )
nil) )
) ) )
Previous slide
Next slide
Back to first slide
View graphic version