Ticket #506 (new enhancement)
Opened 21 months ago
Get and put
|Reported by:||Sgeo||Owned by:||toups|
I think it would make sense to include get, put, and modify for the state monad, or perhaps call them state-get state-put state-modify. Could also make state-put and state-modify not return useful values, but not sure if there's a reason to do that.
(define state-get (lambda (state) (state-doublet state state))) (define (state-put new-state) (lambda (old-state) (state-doublet new-state new-state))) (define (state-modify modifier) (lambda (old-state) (define result (modifier old-state)) (state-doublet result result)))