From a1f09d1f143012570a62bcb2a8fe51c439ad68fb Mon Sep 17 00:00:00 2001 From: Gabriel Arakaki Giovanini Date: Fri, 18 Aug 2023 21:57:47 +0200 Subject: feat: Make mosaic reusable --- pkg/list/list.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'pkg/list/list.go') diff --git a/pkg/list/list.go b/pkg/list/list.go index 3aa9d65..b6b6b89 100644 --- a/pkg/list/list.go +++ b/pkg/list/list.go @@ -13,15 +13,15 @@ type Pair[T, U any] struct { Right U } -func Chunck[T any](slice []T, size int) [][]T { +func Distribuite[T any](slice []T, size int) [][]T { chuncks := make([][]T, size) for i := 0; i < len(slice); i += size { for x := 0; x < size; x++ { end := i + x - if end > len(slice) { - break + if end >= len(slice) { + return chuncks } chuncks[x] = append(chuncks[x], slice[end]) -- cgit v1.2.3