Skip to content

Instantly share code, notes, and snippets.

@arohner
Created July 27, 2010 17:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arohner/492566 to your computer and use it in GitHub Desktop.
Save arohner/492566 to your computer and use it in GitHub Desktop.
(defmacro nth->
"Fast lookup into nested vectors. Indices must be ints"
[coll [id & idx]]
(let [coll (with-meta coll {:tag Indexed})]
(if (seq idx)
`(nth-> (.nth ~coll ~id) ~idx)
`(.nth ~coll ~id))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment