You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Data.List, there is a function that maps over a collection while building an accumulator:
mapAccumL :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c)
Specialized to Array, this would be:
mapAccumL :: (a -> b -> (a, c)) -> a -> Array b -> (a, Array c)
This is basically a combination of foldl and map. There is a less expressive variant of this where the accumulator is a Monoid and you do not inspect it (a comparison to the contrast between Writer and State is apt here). This variant looks like this:
mapAccumMonoid :: Monoid a => (b -> (a, c)) -> Array b -> (a, Array c)
I use this function somewhat often. I've thought about adding it to primitive, but I'm going to just add it to contiguous for the time being. Just wanted to get these thoughts written down somewhere.
The text was updated successfully, but these errors were encountered:
In Data.List, there is a function that maps over a collection while building an accumulator:
Specialized to
Array
, this would be:This is basically a combination of
foldl
andmap
. There is a less expressive variant of this where the accumulator is aMonoid
and you do not inspect it (a comparison to the contrast betweenWriter
andState
is apt here). This variant looks like this:I use this function somewhat often. I've thought about adding it to
primitive
, but I'm going to just add it to contiguous for the time being. Just wanted to get these thoughts written down somewhere.The text was updated successfully, but these errors were encountered: