Back to Lo

It Trimprefix

docs/data/it-trimprefix.md

1.53.0344 B
Original Source

TrimPrefix removes all the leading prefix from the collection.

go
collection := func(yield func(int) bool) {
    yield(1)
    yield(2)
    yield(1)
    yield(2)
    yield(3)
}

trimmed := it.TrimPrefix(collection, []int{1, 2})
var result []int
for item := range trimmed {
    result = append(result, item)
}
// result contains [1, 2, 3]