I came across pi.go <https://golang.org/doc/play/pi.go> in the examples for go-lang. I've been trying to replicate it with core.async, and this is what I have till now:
(defn term [ch k] > (go (>! ch (-> 4.0 > (* (Math/pow -1 k)) > (/ (-> k (* 2) (+ 1))))))) > > (defn pi [n] > (let [ch (chan) > f (atom 0)] > (dotimes [k (inc n)] > (term ch k)) > (dotimes [k (inc n)] > (swap! f + (<!! (go (<! ch))))) > @f)) > > (defn -main [] > (pi 5000)) This is more or less a direct translation and pretty ugly. Also, it throws an interminable stacktrace. What would be the right way to do this? -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.