Created
May 31, 2012 13:30
-
-
Save yuanmai/2843435 to your computer and use it in GitHub Desktop.
Clojure 代码优化
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
;; f需要被调用很多次,假设g的运算非常耗时,而在循环中a的值是不变的,b每次不一样,是否有自动的方法把f转化成curry形式,从而提高性能? | |
(defn f [a b] | |
(let [gb (g b) | |
ga (g a) | |
gga (g ga)] | |
(+ gga gb))) | |
=> | |
(defn f [a] | |
(let [ga (g a) | |
gga (g ga)] | |
(fn [b] | |
(let [gb (g b)] | |
(+ gga gb))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment