slice

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: May 22, 2022 License: BSD-2-Clause Imports: 0 Imported by: 0

Documentation

Overview

Package slice provides common utility functions to Go slices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter added in v0.0.6

func Filter[A any](as []A, p func(a A) bool) (res []A)

Filter filters slice values.

func FlatMap

func FlatMap[A any, B any](as []A, f func(A) []B) (bs []B)

FlatMap converts all values of a slice using the provided function. As the function returns slices, all of them are appended to a single long slice.

func Flatten added in v0.0.8

func Flatten[A any](ass [][]A) (aas []A)

Flatten simplifies a slice of slices to just a slice.

func FoldLeft

func FoldLeft[A any, B any](as []A, zero B, f func(B, A) B) (res B)

FoldLeft folds all values in the slice using the combination function.

func Map

func Map[A any, B any](as []A, f func(A) B) (bs []B)

Map converts all values of a slice using the provided function.

Types

type Set added in v0.0.6

type Set[A comparable] map[A]struct{}

Set is a way to represent sets in Go.

func ToSet added in v0.0.6

func ToSet[A comparable](as []A) (s Set[A])

ToSet converts a slice to a set.

Jump to

Keyboard shortcuts

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