Your core loop seems to be:
(loop [zr (double 0.0)
zi (double 0.0)
zr2 (double 0.0)
zi2 (double 0.0)
iterations-remaining iterations-remaining]
(if (and (not (neg? iterations-remaining))
(< (+ zr2 zi2) limit-square))
(let [new-zi (double (+ (* (* f2 zr) zi) pi))
new-zr (double (+ (- zr2 zi2) pr))
new-zr2 (double (* new-zr new-zr))
new-zi2 (double (* new-zi new-zi))]
(recur new-zr new-zi new-zr2 new-zi2 (dec iterations-remaining)))
What I suggest is
(loop [zr (double 0.0)
zi (double 0.0)
i (int (inc iterations-remaining))]
(let [zr2 (* zr zr)
zi2 (* zi zi)]
(if (and (not (= 0 i)) (< (+ zr2 zi2 limit-square)))
(recur (+ (- zr2 zi2) pr) (+ (* (* f2 zr) zi) pi) (unchecked-inc i))
(whatever...))))
* Same calculations
* Less items in recur rebind
* Counter is also primitive
(untested, may need slight tweakage)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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
-~----------~----~----~----~------~----~------~--~---