Created
March 17, 2010 21:33
-
-
Save floere/335733 to your computer and use it in GitHub Desktop.
This file contains 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
#; named lambda klass | |
#; in an environment with counter set to 0 | |
#; define an anonymous lambda which increases the counter by one | |
# | |
# (defun klass () | |
# (let ((counter 0)) | |
# (lambda () (incf counter)))) | |
;klass = lambda { | |
; counter = 0 | |
; lambda { counter += 1 } | |
;} | |
; | |
;object = klass[] | |
;puts object[] # => 1 | |
;puts object[] # => 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment