Re:An example of fast numerical computation using Haskell
by cbp on Saturday November 30, 2013 @02:55PM
(#6824357)
Since you know the division in collatz-next is always exact you can change / for quot or a bit-shift-right. That should improve it somewhat. You should also typehint with ^long the arguments to your functions. Further than that I would probably compile the code and then use a decompiler to check for boxing. But I can't say I've done much math intensive programming in clojure.
[ Parent
| on HN ]
Re:An example of fast numerical computation using Haskell
by wging on Saturday November 30, 2013 @09:35PM
(#6825804)
Nice.
4.5 -> 2.7 seconds on my machine when using 'quot' instead of '/'.
2.4 seconds when hinting ^long in argument of collatz-length.
1.6 when also hinting ^long in collatz-next. Interestingly, when I hint only in collatz-next it takes 1.5.
Re:An example of fast numerical computation using Haskell
by glogla on Sunday December 01, 2013 @03:15AM
(#6826594)
Thanks! I was completely unaware that such type-hinting existed.
I was also unsure if loop/recur was a good loop paradigm for this kind of problem (maybe for with variable would be better?) but I'd say in 1/3 speed of C it's pretty good for Clojure :)