mapAccumL package:storablevector

The mapAccumL function behaves like a combination of map and foldl; it applies a function to each element of a Vector, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new list.