(with-monad state-m
(defn interval
[a b]
"Transform a sequence of uniform random numbers in the interval [0, 1)
into a sequence of uniform random numbers in the interval [a, b)."
(let [d (- b a)
f (if (zero? a)
(if (= d 1)
identity
(fn [r] (* d r)))
(if (= d 1)
(fn [r] (+ a r))
(fn [r] (+ a (* d r)))))]
(m-fmap f stream-next))))
Comments top
No comments for interval. Log in to add a comment.