Skip to content

Commit

Permalink
slice: cap batches and chunks to their length
Browse files Browse the repository at this point in the history
  • Loading branch information
creachadair committed Sep 11, 2024
1 parent 83390c6 commit 2f82efd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions slice/slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func Chunks[T any, Slice ~[]T](vs Slice, n int) []Slice {
i := 0
for i < len(vs) {
end := min(i+n, len(vs))
out = append(out, vs[i:end])
out = append(out, vs[i:end:end])
i = end
}
return out
Expand Down Expand Up @@ -262,7 +262,7 @@ func Batches[T any, Slice ~[]T](vs Slice, n int) []Slice {
end++
rem--
}
out = append(out, vs[i:end])
out = append(out, vs[i:end:end])
i = end
}
return out
Expand Down

0 comments on commit 2f82efd

Please sign in to comment.