slice

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

README

Slice

Installation

go get github.com/jin06/pkg/slice

Examples

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chunk

func Chunk[T any](source []T, size int) (dest [][]T)

Chunk Creates an array of elements split into groups the length of size.If array can't be split evenly, the final chunk will be the remaining elements.

Example
anySource := []any{1, 2, 3, "jk", true, 0.069}
intSource := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
stringSource := []string{"a", "b", "c"}
fmt.Println("any: ", Chunk(anySource, 2))
fmt.Println("int:", Chunk(intSource, 5))
fmt.Println("string:", Chunk(stringSource, 2))
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL