Re: idiom questions

2009-10-30 Thread Adrian Cuthbertson
> (let [x nil] > ;; do something and modify 'x' > ) > >how does one modify the value of 'x' ? Hi Chick, there's nothing stopping you re-binding x within the let construct, eg; (defn myfn [x] (let [x (if (or (nil? x) (< x 0.2)) 0.0 x) x (if (>= x 0.8) 1.0 x)]

Re: idiom questions

2009-10-30 Thread Alex Osborne
Alex Osborne wrote: > Chick Corea wrote: >> If I understand correctly, the "(binding ...)" macro specifically >> applies to >> "Variables", one of Clojure's STM types, thus has dynamic, thead-local >> scope. Is that right? In which case, it may hide a lexical binding ? > > Yes, I think you are

Re: idiom questions

2009-10-30 Thread Alex Osborne
Chick Corea wrote: > Is everything in Clojure immutable? Most things. Clojure tries very hard to be thread-safe by default. > how does one modify the value of 'x' ? > > (let [x nil] (def x true)) One does not, at least not in a let-binding. If you really want a lexical variable you

Re: idiom questions

2009-10-30 Thread Howard Lewis Ship
When I first looked at Clojure, I didn't get it (I scanned the docs for 10 - 15 minutes). A few month later, Stu Halloway said to give it a second look and boy am I glad I did. Go read Stu's book, or at least the first couple of chapters online at Manning. Digest for a bit. It'll be an eye opene

Re: idiom questions

2009-10-30 Thread David Nolen
On Fri, Oct 30, 2009 at 4:42 PM, Chick Corea wrote: > > Is everything in Clojure immutable? For example, w/ this code-snippet > > (let [x nil] > ;; do something and modify 'x' > ) > > how does one modify the value of 'x' ? > >(let [x nil] (def x true)) > >

idiom questions

2009-10-30 Thread Chick Corea
Is everything in Clojure immutable? For example, w/ this code-snippet (let [x nil] ;; do something and modify 'x' ) how does one modify the value of 'x' ? (let [x nil] (def x true)) this doesn't work. the "def' interns and defines a (dynamic) root- b