aboutsummaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-08-17 21:38:27 +0200
committerGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-08-17 21:38:27 +0200
commitd2a9e162352646e7f1550823c3d88496590f8760 (patch)
treef1dfe1f93e8d943443239d804569ec8ca7beb9f8 /pkg
parent969b7600a86185187cd17d45bd252143db4a6728 (diff)
downloadlens-d2a9e162352646e7f1550823c3d88496590f8760.tar.gz
lens-d2a9e162352646e7f1550823c3d88496590f8760.tar.bz2
lens-d2a9e162352646e7f1550823c3d88496590f8760.zip
ref: Update mosaic to remove empty spaces
Diffstat (limited to 'pkg')
-rw-r--r--pkg/list/list.go19
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)