Created
August 17, 2011 13:15
-
-
Save cemerick/1151504 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
| => (defmacro apply. | |
| [method-name & object+args] | |
| `(~method-name ~@(flatten object+args))) | |
| #'user/apply. | |
| => (apply. .substring "foobar" [0 4]) | |
| "foob" | |
| ; above works only at compile time, so won't work with seqs of undetermined length at runtime. A sane place to use eval: | |
| => (def k [0 4]) | |
| #'user/k | |
| => (def string "foobar") | |
| #'user/string | |
| => (eval `(.substring ~string ~@k)) | |
| "foob" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment