aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/clojure/contrib/probabilities/finite_distributions.clj8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/clojure/contrib/probabilities/finite_distributions.clj b/src/clojure/contrib/probabilities/finite_distributions.clj
index 861cdc65..c1dd3a88 100644
--- a/src/clojure/contrib/probabilities/finite_distributions.clj
+++ b/src/clojure/contrib/probabilities/finite_distributions.clj
@@ -32,11 +32,9 @@
[m-result (fn m-result-dist [v]
{v 1})
m-bind (fn m-bind-dist [mv f]
- (letfn [(add-prob [dist [x p]]
- (assoc dist x (+ (get dist x 0) p)))]
- (reduce add-prob {}
- (for [[x p] mv [y q] (f x)]
- [y (* q p)]))))
+ (reduce (partial merge-with +)
+ (for [[x p] mv [y q] (f x)]
+ [y (* q p)])))
])
; Applying the monad transformer maybe-t to the basic dist monad results