Re: SICP sqrt function generates unexpected NullPointerException

2011-10-16 Thread Alan Malloy
An infinite loop on large inputs is unrelated to his null-pointer problem. As SICP makes clear, the imprecision of floating-point arithmetic means this particular algorithm will not terminate for large inputs. That is, rounding errors stop it from making progress when the numbers are large and the

Re: SICP sqrt function generates unexpected NullPointerException

2011-10-16 Thread Timo Grodzinski
+1 hangs with Clojure 1.2.1 in Slimes REPL on Java 1.6.0_26 (Ubuntu) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with

Re: SICP sqrt function generates unexpected NullPointerException

2011-10-14 Thread Alan O'Donnell
Armando, I get the same behavior as you with Clojure 1.2.1. But if I lein dep Clojure 1.3.0, I'm back to NullPointerExceptions. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that po

Re: SICP sqrt function generates unexpected NullPointerException

2011-10-14 Thread Armando Blancas
With 1.3/OSX this code worked up to: user=> (sqrt 1) 100.0 and then hanged here: user=> (sqrt 10) ~ $ On Oct 13, 7:04 pm, "Alan O'Donnell" wrote: > Hi everyone, > > I've encountered an unexpected NullPointerException while translating > some early SICP code into Clo

SICP sqrt function generates unexpected NullPointerException

2011-10-14 Thread Alan O'Donnell
Hi everyone, I've encountered an unexpected NullPointerException while translating some early SICP code into Clojure 1.3.0. In particular, I'm implementing the iterative sqrt procedure from section 1.1.7. Here's my code: (defn square [x] (* x x)) (defn abs [x] (cond (< x 0) (- x) :els