Skip to content

Instantly share code, notes, and snippets.

@yuanmai
Created May 31, 2012 13:30
Show Gist options
  • Save yuanmai/2843435 to your computer and use it in GitHub Desktop.
Save yuanmai/2843435 to your computer and use it in GitHub Desktop.
Clojure 代码优化
;; 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