Last active
October 30, 2019 21:12
-
-
Save chelseatroy/7b98c34539a124f1664a81e44d20b5f7 to your computer and use it in GitHub Desktop.
Environments as Objects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 3.1 | |
(define (make-counter value) | |
(define (incr x) | |
(set! value (+ value x)) | |
value) | |
incr) | |
(define counter (make-counter 100)) | |
; > (counter 100) | |
; 200 | |
; > (counter -1) | |
; 199 | |
; > (counter 10) | |
; 209 | |
; > (counter -150) | |
; 59 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment