Re: A little help needed in understnding anonymous functions

2009-08-27 Thread Sourav
I knew I was missing something...!! Thanks all for your help! :) On Aug 27, 12:19 am, Scott Moonen wrote: > Hi Soura.  I think you have an extra set of parentheses in your second > example, on the line with dosync.  It should read: > > (defn foo2 [n] >  (let [r (ref n)] >    #(dosync >        (a

Re: A little help needed in understnding anonymous functions

2009-08-26 Thread Scott Moonen
Hi Soura. I think you have an extra set of parentheses in your second example, on the line with dosync. It should read: (defn foo2 [n] (let [r (ref n)] #(dosync (alter r + %) @r))) -- Scott On Wed, Aug 26, 2009 at 2:40 PM, Sourav wrote: > > Hi, > > I'm new to clojure and came fr

Re: A little help needed in understnding anonymous functions

2009-08-26 Thread Emeka
(defn foo2 [n] (let [r (ref n)] #(dosync (alter r + %) @r))) Something went wrong, I am resending the code. Regards, Emeka --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send

Re: A little help needed in understnding anonymous functions

2009-08-26 Thread Emeka
On Wed, Aug 26, 2009 at 6:40 PM, Sourav wrote: > > Hi, > > I'm new to clojure and came from a Lisp background. While learning I > clojure I came accross the two different ways of creating anonymous > functions ((fn ...) and #(...)). I tried to construct the accumulator > function in clojure using

Re: A little help needed in understnding anonymous functions

2009-08-26 Thread Meikel Brandmeyer
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 [] ((

A little help needed in understnding anonymous functions

2009-08-26 Thread Sourav
Hi, I'm new to clojure and came from a Lisp background. While learning I clojure I came accross the two different ways of creating anonymous functions ((fn ...) and #(...)). I tried to construct the accumulator function in clojure using these forms and this is what I wrote (this might seem naive