Skip to content

Instantly share code, notes, and snippets.

@cemerick
Created August 17, 2011 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cemerick/1151504 to your computer and use it in GitHub Desktop.
Save cemerick/1151504 to your computer and use it in GitHub Desktop.
=> (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