Hi, Am 26.08.2009 um 20:40 schrieb Sourav:
(defn foo2 [n]
(let [r (ref n)]
#((dosync
(alter r + %) @r))))
One pair of parentheses too much...
(defn foo2
[n]
(let [r (ref n)]
#(dosync (alter r + %))))
What you wrote is #((foo)) which translates to (fn [] ((foo))). foo
returns in your case an integer. You get eg. ((foo)) => (5). So you
try to call an integer like a function. This can't work and hence you
get the exception you described. Removing one pair of parentheses
fixes the problem: #(foo) => (fn [] (foo)) and thus (foo) => 5.
Hope this helps. Sincerely Meikel
smime.p7s
Description: S/MIME cryptographic signature
