Skip to content

Instantly share code, notes, and snippets.

@sw-samuraj
Last active March 20, 2017 21:06
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 sw-samuraj/1e3e8f95e7daf0d5d245a73717c707f0 to your computer and use it in GitHub Desktop.
Save sw-samuraj/1e3e8f95e7daf0d5d245a73717c707f0 to your computer and use it in GitHub Desktop.
An example of re-binding of the Var containing a composite function.
(defn cube [x] (Math/pow x 3))
(defn cube-root [x] (Math/pow x 1/3))
(defn ^:dynamic prettify [x] (Math/round x))
(defn compute [] (prettify (cube-root (cube 42))))
(compute)
;; -> 42
(binding [prettify #(Integer/toString % 2)] (compute))
;; -> "101001"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment