2015-09-25 48 views

回答

5

count時返回2不是一個可變變量所以(+ count 1)不改變其值。如果您想要突變,您可以將計數存儲在​​中並使用swap!進行更新:

(defn counter [] 
    (let [count (atom 0)] 
    (fn [] (swap! count inc))))