Re: distinct broken?

2008-12-29 Thread Christophe Grand
Fixed (rev 1190) tristan a écrit : > Thanks for the explanation Christophe. > I really need to try use (for) more often. I seem to forget about it > all the time. > > On Dec 27, 10:42 pm, Christophe Grand wrote: > >> tristan a écrit : >> >> >>> Hi All, >>> >>> I've been trying to

Re: distinct broken?

2008-12-28 Thread Christophe Grand
Rich Hickey a écrit : > The right thing I think is to represent as Integer and Long whenever > possible, and do overflow checking (as is done in the static > add(long,long) etc) rather than pre-op upconversion to next size. This > would require the addition of a LongOps etc. > I see. > I'

Re: distinct broken?

2008-12-28 Thread Rich Hickey
On Dec 28, 2008, at 5:27 AM, Christophe Grand wrote: > > Mark Engelberg a écrit : >> So one thing I don't get is why would tristan's pow code sometimes >> generate a BigInteger, and sometimes a Long for the same resulting >> number? >> > Good question. > > (pow 2 32); returns 4294967296 (BigInte

Re: distinct broken?

2008-12-28 Thread Christophe Grand
Mark Engelberg a écrit : > So one thing I don't get is why would tristan's pow code sometimes > generate a BigInteger, and sometimes a Long for the same resulting > number? > Good question. (pow 2 32); returns 4294967296 (BigInteger) (pow 4 16); returns 4294967296 (Long) (pow 16 8); returns 42

Re: distinct broken?

2008-12-27 Thread tristan
Thanks for the explanation Christophe. I really need to try use (for) more often. I seem to forget about it all the time. On Dec 27, 10:42 pm, Christophe Grand wrote: > tristan a écrit : > > > Hi All, > > > I've been trying to learn clojure lately by solving the project euler > > problems with i

Re: distinct broken?

2008-12-27 Thread Mark Engelberg
So one thing I don't get is why would tristan's pow code sometimes generate a BigInteger, and sometimes a Long for the same resulting number? But if this is really the problem, it seems like before hashing a number, Clojure should apply some sort of consistent type conversion rule to make sure th

Re: distinct broken?

2008-12-27 Thread Christophe Grand
tristan a écrit : > Hi All, > > I've been trying to learn clojure lately by solving the project euler > problems with it, and I think the distinct function is broken (or it > doesn't quite work as I assume it would). > > here is the code i'm running > > > (defn pow [nbr pwr] > (if (< pwr 2) >

distinct broken?

2008-12-26 Thread tristan
Hi All, I've been trying to learn clojure lately by solving the project euler problems with it, and I think the distinct function is broken (or it doesn't quite work as I assume it would). here is the code i'm running (defn pow [nbr pwr] (if (< pwr 2) nbr (* nbr (pow nbr (dec pwr