Re: Regarding lexical scoping and usage of 'let' in a recursive function call

2010-11-12 Thread André Ferreira
Well, a more important matter, this example in the documentation of atom is wrong! The recursive calls will not be memoized if called like that. Running this code clearly shows: (defn memoize [f] (let [mem (atom {})] (fn [& args] (if-let [e (find @mem args)] (val e) (le

Re: Regarding lexical scoping and usage of 'let' in a recursive function call

2010-11-12 Thread Joseph Smith
In this case 'memoize' returns a memoized version of the function 'f', which closes over 'mem'. Each time 'memoize' is called a new atom is created, not each time the function it returns is called. --- Joseph Smith j...@uwcreations.com On Nov 11, 2010, at 2:06 PM, Manoj wrote: > I am a n

Re: Regarding lexical scoping and usage of 'let' in a recursive function call

2010-11-11 Thread Ken Wesson
On Thu, Nov 11, 2010 at 3:06 PM, Manoj wrote: > I am a newbie to Clojure, so have some confusion around lexical > scoping especially when "let" is used in a recursive function call. To > be more precise, I am taking the example memoize() function used for > explaining the concept of atom at clojur

Regarding lexical scoping and usage of 'let' in a recursive function call

2010-11-11 Thread Manoj
I am a newbie to Clojure, so have some confusion around lexical scoping especially when "let" is used in a recursive function call. To be more precise, I am taking the example memoize() function used for explaining the concept of atom at clojure.org. Here is how it is explained: (defn memoize [f]