underscore
GitHub Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Chunk

Chunk splits a slice into groups of size n. The last chunk may be smaller.

package main

import (
 "fmt"
 u "github.com/rjNemo/underscore"
)

func main() {
 fmt.Println(u.Chunk([]int{1,2,3,4,5}, 2)) // [[1 2] [3 4] [5]]
}