Return the reduction of (m-lift 2 f) over the list of monadic values mvs
with initial value (m-result val).
(defmonadfn m-reduce
"Return the reduction of (m-lift 2 f) over the list of monadic values mvs
with initial value (m-result val)."
([f mvs]
(if (empty? mvs)
(m-result (f))
(let [m-f (m-lift 2 f)]
(reduce m-f mvs))))
([f val mvs]
(let [m-f (m-lift 2 f)
m-val (m-result val)]
(reduce m-f m-val mvs))))
Comments top
No comments for m-reduce. Log in to add a comment.