mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
789 B
789 B
name, slug, sourceRef, category, subCategory, signatures, variantHelpers, similarHelpers, position
| name | slug | sourceRef | category | subCategory | signatures | variantHelpers | similarHelpers | position | ||
|---|---|---|---|---|---|---|---|---|---|---|
| PartitionBy | partitionby | it/seq.go#L26 | it | sequence |
|
|
171 |
PartitionBy returns a sequence of elements split into groups. The order of grouped values is determined by the order they occur in collection. The grouping is generated from the results of running each element of collection through transform.
collection := func(yield func(int) bool) {
yield(1)
yield(2)
yield(3)
yield(4)
yield(5)
yield(6)
}
result := it.PartitionBy(collection, func(x int) int {
return x % 3
})
// result contains [[1, 4], [2, 5], [3, 6]]