about summary refs log tree commit diff stats
path: root/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/prev5.scm
blob: b2a6c274969a921b31415416d6f6049b73eb6b68 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
(define make-previous
  (let ((glob 'first-time))
    (lambda ()
      (let ((old 'first-time))
	(lambda (msg)
	  (cond ((eq? msg 'local)
		 (lambda (arg)
		   (let ((result old))
		     (set! old arg)
		     result)))
		((eq? msg 'global)
		 (lambda (arg)
		   (let ((result glob))
		     (set! glob arg)
		     result)))
		(else (error "No such method" msg)) ))))))