Skip to content

Instantly share code, notes, and snippets.

@rdsr
Created November 1, 2010 09:00
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 rdsr/657857 to your computer and use it in GitHub Desktop.
Save rdsr/657857 to your computer and use it in GitHub Desktop.
(defn contextual-eval [ctx expr] ;; from Joy of clojure
(eval
`(let ~(vec (mapcat #(list % `('~ctx '~%)) (keys ctx)))
~expr)))
(defn contextual-eval ;; alternative
[ctx expr]
(eval
`(let ~(vec (apply concat ctx))
~expr)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment