Last active
October 29, 2015 06:56
-
-
Save gengar/82787aabb4fc0b27228e 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
(define ~/default | |
(case-lambda | |
((obj index default) | |
(ref obj index default)) | |
((obj index i x . xs) | |
(apply ~/default | |
(ref obj index) | |
i x xs)))) | |
(define-syntax ~~ | |
(syntax-rules () | |
((_ args ...) | |
(letrec ((recur | |
(case-lambda | |
((obj index args ...) | |
(ref obj index args ...)) | |
((obj index args ... x . xs) | |
(apply recur | |
(ref obj index) | |
args ... x | |
xs))))) | |
recur)))) | |
;; gosh> (define ht (make-hash-table)) | |
;; ht | |
;; gosh> ((~~ default) ht 'foo 'bar) | |
;; bar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment