Skip to content

Instantly share code, notes, and snippets.

@floere
Created March 17, 2010 21:33
Show Gist options
  • Save floere/335733 to your computer and use it in GitHub Desktop.
Save floere/335733 to your computer and use it in GitHub Desktop.
#; 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