cerrado @ c7a8aa113a914e70e027fea93265c7232b865b5e

 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 FirstOrZero[T any](v []T) T {
12	if len(v) == 0 {
13		var zero T
14		return zero
15	}
16	return v[0]
17}
18
19func ChunkBy[T any](items []T, chunkSize int) [][]T {
20	var chunks = make([][]T, 0, (len(items)/chunkSize)+1)
21	for chunkSize < len(items) {
22		items, chunks = items[chunkSize:], append(chunks, items[0:chunkSize:chunkSize])
23	}
24	return append(chunks, items)
25}