Hey Konrad, I was looking at the probability monad today and think this definition of m-bind might be easier to understand.
(defmonad dist-m [m-result (fn m-result-dist [v] {v 1}) m-bind (fn m-bind-dist [mv f] (reduce (partial merge-with +) (for [[x p] mv [y q] (f x)] {y (* q p)}))) ]) What do you think? Also, I was thinking about cond-dist-m. What if dist-m was redefined to be this (defmonad dist-m [m-result (fn m-result-dist [v] {v 1}) m-bind (fn m-bind-dist [mv f] (if (empty? mv) {} (reduce (partial merge-with +) (for [[x p] mv [y q] (f x)] {y (* q p)})))) m-zero {} m-plus (fn m-plus-dist [& mvs] (if-let [mv (first (drop-while empty? mvs))] mv {})) ]) I think that would roll cond-dist-m into dist-m, eliminating the need for a seperate monad. Don't know if you'd thought of that and discarded it or not. Love the work you've done to bring monads to Clojure. Jim -- 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