Open
Conversation
samber reviewed Jan 22, 2026
| // SliceToSeq2 converts a slice into a sequence of pairs (key, value). | ||
| // Elements are paired consecutively: s[0] with s[1], s[2] with s[3], etc. | ||
| // If the slice has an odd number of elements, the last element is paired with the zero value of type E. | ||
| func SliceToSeq2[Slice ~[]E, E any](collection Slice) iter.Seq2[E, E] { |
Owner
There was a problem hiding this comment.
I would rename it Pairwise.
See the samber/ro implem: https://ro.samber.dev/docs/operator/combining#pairwise
Please write 2 implementations:
- core package -> returns
[][]Tor[]T2[T, T] it/package -> returnsiter.Seq[[]T]oriter.Seq[T2[T, T]]
Using iter.Seq2 does not seem a good idea here, since first argument of Seq2 is expected to be a key.
I would use T2 tuples instead of simple slices []T.
samber reviewed Jan 22, 2026
| module github.com/samber/lo | ||
| | ||
| go 1.18 | ||
| go 1.25 |
Owner
There was a problem hiding this comment.
Please revert. I try to keep a good compatiibility with older go versions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
a great method