Skip to content

Instantly share code, notes, and snippets.

@chelseatroy

chelseatroy/state.scm

Last active Oct 30, 2019
Embed
What would you like to do?
Environments as Objects
; 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
You can’t perform that action at this time.