An optimized implementation of m-until for the state monad that
replaces recursion by a loop.
(defn state-m-until
"An optimized implementation of m-until for the state monad that
replaces recursion by a loop."
[p f x]
(letfn [(until [p f x s]
(if (p x)
[x s]
(let [[x s] ((f x) s)]
(recur p f x s))))]
(fn [s] (until p f x s))))
Comments top
No comments for state-m-until. Log in to add a comment.