At least I believe so: it would allow client code to set the desired precision once and then be able to invoke functions that take an optional precision parameter (or none at all) without having to specify precision every time.
For example: (set! *default-precision* (. java.math.MathContext/DECIMAL128 getPrecision)) (defn harmonic-number ([] ((fn more [sum n] (let [new-sum (+ sum (with-precision *default- precision* :rounding HALF_EVEN (/ 1 (bigdec n))))] (lazy-seq (cons (bigdec new-sum) (more new-sum (inc n)))))) 0 1)) ([n] (harmonic-number n *default-precision*)) ([n #^Integer precision] (reduce + (map #(with-precision precision :rounding HALF_EVEN (/ 1 (bigdec %))) (range 1 (inc n))))) ) user=> (harmonic-number 5) 2.2833333333333333333333333333333333M user=> (take 10 (harmonic-number)) (1M 1.5M 1.8333333333333333333333333333333333M 2.0833333333333333333333333333333333M 2.2833333333333333333333333333333333M 2.4500000000000000000000000000000000M 2.5928571428571428571428571428571429M 2.7178571428571428571428571428571429M 2.8289682539682539682539682539682540M 2.9289682539682539682539682539682540M) Any thoughts? Is there another way to accomplish this that I have overlooked? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---