We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Awful mutability....
def finish[V:Semigroup](in: Iterator[V]): Iterator[(Option[V], V)] = { var prev: Option[V] = None in.map { v => val stored = prev prev = Some(prev.map(Semigroup.plus(_, v)).getOrElse(v)) (stored, v) } }
The text was updated successfully, but these errors were encountered:
Don't feel badly about the var... Iterator's scanLeft (which returns another lazy Iterator) also uses the same var approach! :) https://github.com/scala/scala/blob/master/src/library/scala/collection/Iterator.scala#L487
scanLeft
Sorry, something went wrong.
@johnynek where do you want to use this? What's the issue? I guess the task is to add this to the Semigroup object?
No branches or pull requests
Awful mutability....
The text was updated successfully, but these errors were encountered: