Re: futures - The Joy Of Clojure book question

2013-08-03 Thread Ryan Moore
Thanks guys. I had a feeling that it wasn't doing the calculation twice the way it was coded in the book. Ryan On Tuesday, July 23, 2013 11:23:21 AM UTC-4, Lars Nilsson wrote: > > On Tue, Jul 23, 2013 at 11:12 AM, Baishampayan Ghose > > > wrote: > > It's definitely got to do with the code, th

Re: futures - The Joy Of Clojure book question

2013-07-23 Thread Lars Nilsson
On Tue, Jul 23, 2013 at 11:12 AM, Baishampayan Ghose wrote: > It's definitely got to do with the code, the right way to test it out > will be to wrap the form in a function and then calling it twice. Like > so - > > (time > (let [x (fn [] (Thread/sleep 2000) >(+ 1 1))] >

Re: futures - The Joy Of Clojure book question

2013-07-23 Thread Baishampayan Ghose
It's definitely got to do with the code, the right way to test it out will be to wrap the form in a function and then calling it twice. Like so - (time (let [x (fn [] (Thread/sleep 2000) (+ 1 1))] [(x) (x)])) ;=> "Elapsed time: 4002.0 msecs" ;=> [2 2] Hope that helps

futures - The Joy Of Clojure book question

2013-07-23 Thread Ryan Moore
There is an example in the book The Joy of Clojure on p.262 that uses futures that I evaluated in the REPL. user> (time (let [x (future (do (Thread/sleep 2000) (+ 1 1)))] [@x @x])) "Elapsed time: 2000.809 msecs" [2 2] I figured that taking out the future would cause the execution to t