I was using 1.2, I thought I posted that here but I don't see the
message.  I don't have the same problem in 1.3, but I have some
slightly tangental questions.

1.  How do I get leiningen to use 1.3 when I type lein repl, right now
I have to compile a jar and execute it if I want to use the 1.3
library.
2.  I ran out of memory, and messing around with the java settings
doesn't seem to do anything, for example, the following jar executions
both give me an OutOfMemory exception when my loop gets up to about
540000

lein uberjar
java -jar euler-1.0.0-SNAPSHOT-standalone.jar
java -jar euler-1.0.0-SNAPSHOT-standalone.jar -Xms2048m -Xmx4096m

On Oct 7, 4:14 pm, Mark Engelberg <mark.engelb...@gmail.com> wrote:
> On Thu, Oct 7, 2010 at 12:29 PM, Jarl Haggerty <fictivela...@gmail.com> wrote:
> > I'm using clojure 1.2
>
> OK, I stand corrected.  Stuart's right.  The problem is that you're
> getting mixed numeric types.
> When you do (collatz 113383) the sequence eventually hits
> 2482111348
> which is a Long, not an Integer.
> When you divide by 2,
> (/ 249211348 2) you should get back an Integer, but instead, you get
> back a Long.
> This continues until eventually you're bouncing back and forth between
> 1, 2, and 4 which are Longs rather than Integers, and thus aren't
> being found in your hash map.
>
> My understanding is that Clojure 1.2 is supposed to auto-reduce all
> arithmetic operations specifically to avoid situations like this.
> Therefore, I believe it is a bug that (/ 249211348 2) returns a Long
> rather than an Integer.
>
> Unfortunately, I don't know whether anyone is likely to fix it, since
> Clojure 1.3 is pursuing an entirely different arithmetic strategy.
>
> The quickest fix for your particular situation is to use quot
> (quotient) rather than /, since quot properly auto-reduces.
> Another workaround (for example, if you don't know in advance that the
> first operand is divisible by the second) is to call
> clojure.lang.Numbers/reduce after each division.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to