On 08.01.2010, at 06:21, joel r wrote:

But right now I need some help. Either I'm using dist-m wrong, or it's
a bug I've found.

It's a bug. More specifically, a typo in a recent improvement. It is fixed now, so please try again with the current version - or in fact go back to an older version before December 28.

BTW, I suppose that instead of

(domonad dist-m
        [a die
        b die]
        [+ a b])

you want

(domonad dist-m
        [a die
        b die]
        (+ a b))

i.e. the distribution of the sum of two dice.

I modified dist-m to evaluate a map instead of a vector, like this:

(defmonad dist2-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)})))
  ])

That's exactly the right fix!

Konrad.

-- 
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

Reply via email to