Created
October 14, 2011 10:22
-
-
Save shirok/1286756 to your computer and use it in GitHub Desktop.
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
(use gauche.threads) | |
(define (runonce fn) | |
(let1 state (atom #f) ; once run, becomes (list result) | |
(values (^[] (atomic state boolean)) ;has-run? | |
(^[] (atomic-update! state (^_ #f))) ;reset | |
(^ args ;once | |
(car (atomic-update! state (^p (or p `(,(apply fn args)))))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment