Add Iterable.intersperse extension method #309
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I needed something that could add an element between each two elements in a list as I just hardcoded that functionality in my flutter app but now have decided to revise that code so did some research about it as I didn't even know what name that has and eventually reached to https://github.com/apple/swift-algorithms/blob/main/Guides/Intersperse.md which itself is linked to https://hackage.haskell.org/package/base-4.14.0.0/docs/Data-List.html#v:intersperse and https://docs.rs/itertools/0.9.0/itertools/trait.Itertools.html#method.intersperse which felt that makes it enough popular to be added to
collection
. It would be ok also if you would like to rename this to something better.Or maybe we should have two of them,
intersperse
that mutates a list andinterspersed
, the one who returns a new iterator, or maybe we should provide only one and should be namedinterspersed
like swift or we should follow rust and Haskell instead.