如何使用Clojure实现与下面代码相同的功能?

How to achieve the same function as the following code using Clojure?

事实上这是http://www.paulgraham.com/icad.html中的一个问题 Common Lisp代码:

(defun foo (n)
  (lambda (i) (incf n i)))

Python代码:

def foo (n):
    s = [n]
    def bar (i):
        s[0] += i
        return s[0]
    return bar

我想知道如何使用 Clojure 在函数中保存值。

注意这是一个累加器,意思是

(def foo-2 (foo 2))
(foo 2) => 4
(foo 3) => 7
 (defn foo [n]
   (let [accumulate (atom n)]
     (fn [i] (swap! accumulate + i))))

 (def foo-2 (foo 2))

 (foo-2 2)
 => 4
 (foo-2 3)
 => 7