diff options
author | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2023-08-17 21:38:27 +0200 |
---|---|---|
committer | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2023-08-17 21:38:27 +0200 |
commit | d2a9e162352646e7f1550823c3d88496590f8760 (patch) | |
tree | f1dfe1f93e8d943443239d804569ec8ca7beb9f8 /pkg/list | |
parent | 969b7600a86185187cd17d45bd252143db4a6728 (diff) | |
download | lens-d2a9e162352646e7f1550823c3d88496590f8760.tar.gz lens-d2a9e162352646e7f1550823c3d88496590f8760.tar.bz2 lens-d2a9e162352646e7f1550823c3d88496590f8760.zip |
ref: Update mosaic to remove empty spaces
Diffstat (limited to 'pkg/list')
-rw-r--r-- | pkg/list/list.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/pkg/list/list.go b/pkg/list/list.go index dfc3fb7..3aa9d65 100644 --- a/pkg/list/list.go +++ b/pkg/list/list.go @@ -13,6 +13,25 @@ type Pair[T, U any] struct { Right U } +func Chunck[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 + } + + chuncks[x] = append(chuncks[x], slice[end]) + } + + } + + return chuncks +} + func Zip[T, U any](left []T, right []U) []Pair[T, U] { // pick the array with the smaller length l := len(left) |