Map with updatable state

For the record, cats has mapAccumulate which is essentially what you want.

PS: I also proposed to add it to the future stdlib: Add mapWithState · Issue #122 · scala/scala-library-next · GitHub

1 Like