Skip to content

Instantly share code, notes, and snippets.

@crowl
Created December 15, 2015 02:51
Show Gist options
  • Save crowl/e0653edc6e52a810ad7e to your computer and use it in GitHub Desktop.
Save crowl/e0653edc6e52a810ad7e to your computer and use it in GitHub Desktop.
(define once
(let ((called #f))
(lambda (f)
(lambda args
(cond
((not called)
(set! called #t)
(apply f args))
(else args))))))
(define p (once (lambda (x) (* x x))))
(print (p 7))
(print (p 8))
(print (p 9))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment