Phil Hagelberg <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---