Last active
March 20, 2017 21:06
-
-
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.
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
(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