Monad describing stateful computations. The monadic values have the
structure (fn [old-state] [result new-state]).

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/monads.clj:336 top

(defmonad state-m
   "Monad describing stateful computations. The monadic values have the
    structure (fn [old-state] [result new-state])."
   [m-result  (fn m-result-state [v]
	        (fn [s] [v s]))
    m-bind    (fn m-bind-state [mv f]
	        (fn [s]
		  (let [[v ss] (mv s)]
		    ((f v) ss))))
   ])
Vars in clojure.contrib.monads/state-m:
Used in 0 other vars

Comments top

No comments for state-m. Log in to add a comment.