Re: clojure.lang.Atom cannot be cast to a java.lang.Num

2014-05-27 Thread Dylan Gleason
Thank you, Ambrose. It appears I forgot to dereference both index and offset when trying to read the values associated with the atoms. Thanks Phillippe -- I went with your recursive solution and bypassed mutation via atoms altogether -- a much cleaner solution. On Tue, May 27, 2014 at 2:15 AM, Ph

Re: clojure.lang.Atom cannot be cast to a java.lang.Num

2014-05-27 Thread Philippe Guillebert
Also, you should be using loop/recur instead of mutating atoms here, this is the functional way. You already laid out your 2 loop bindings, and a stop condition. This should be straightforward. Philippe. Le 27 mai 2014 09:44, "Dylan Gleason" a écrit : > I am trying to read a TCP request via an

Re: clojure.lang.Atom cannot be cast to a java.lang.Num

2014-05-27 Thread Ambrose Bonnaire-Sergeant
You're adding two atoms together here: (reset! index (+ index offset)) Thanks, Ambrose On Tue, May 27, 2014 at 3:43 PM, Dylan Gleason wrote: > I am trying to read a TCP request via an instance of DataInputStream and > am running into this error with the following code: > > (defn receive > [s

clojure.lang.Atom cannot be cast to a java.lang.Num

2014-05-27 Thread Dylan Gleason
I am trying to read a TCP request via an instance of DataInputStream and am running into this error with the following code: (defn receive [socket] (with-open [reader (DataInputStream. (.getInputStream socket))] (let [length (read-length reader) bytes-in (byte-array length)