Back to Lo

It Trim

docs/data/it-trim.md

1.53.0361 B
Original Source

Trim removes all the leading and trailing cutset from the collection.

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

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