Sat May 8 14:14:27 EDT 2010

Map + state threading.

One of the patterns I use a lot in Scheme is a structure-preserving
recursion (map) over a data structure where some context is updated as
a side effect.  I.e. map over a list with threaded state:

   ((state, in) -> (state, out)) -> state -> [in] -> (state, [out])

What is this abstraction called?  See also [1].

As mentioned in [1], it's really just a state monad which can use the
fmap function.  The important thing is to see the function not as
(s,i) -> (s,o) but as i -> s -> (s,o) which is State when the i is
partially applied.

[1] entry://../meta/20100224-220400