1package u
2
3func First[T any](v []T) (T, bool) {
4 if len(v) == 0 {
5 var zero T
6 return zero, false
7 }
8 return v[0], true
9}
10
11func ChunkBy[T any](items []T, chunkSize int) [][]T {
12 var chunks = make([][]T, 0, (len(items)/chunkSize)+1)
13 for chunkSize < len(items) {
14 items, chunks = items[chunkSize:], append(chunks, items[0:chunkSize:chunkSize])
15 }
16 return append(chunks, items)
17}