Probably.  The Java BigInteger classes are not particularly fast, and do not
seem to be a priority to Sun.  Therefore Clojure is not competitive on large
integer algorithms.

On Wed, Mar 11, 2009 at 2:21 AM, Tassilo Horn <tass...@member.fsf.org>wrote:

>
> Phil Hagelberg <p...@hagelb.org> writes:
>
> Hi Phil,
>
> >> If not, is there better way than inserting gazillions of printlns to
> >> check why and where a function doesn't do the right thing?
> >
> > Most definitely! Break your functions up into smaller pieces, then
> > write tests for them using test-is.  If your functions are hard to
> > test, it's probably because they need to be broken out differently.
>
> Yeah, might be.  To get started with clojure I tried to translate the
> Miller-Rabin pseudo prime algorithm from wikipedia.  Basically it seems
> to work correctly, but the preformance is really bad for numbers above a
> certain limit.
>
> Investigated it a bit more (doing the algorithm step by step in the
> repl) and now I know what's the culprit:  The `expt' function from the
> math contrib library is dead slow.
>
> For number theory you often need things like
>
>    (mod (expt n exp) m)
>
> where the exponent may be very huge.  Is that something which cannot be
> done faster in Clojure because of the Java Integer/BigInteger stuff?
> That would be a shame!  I just fell in love with clojure cause the code
> looks that concise and right!
>
> Bye,
> Tassilo
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
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