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
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