slice

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Copyright 2026 Teradata

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Package slice provides slice utilities (stub for github.com/charmbracelet/x/exp/slice).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chunk

func Chunk[T any](s []T, size int) [][]T

Chunk splits a slice into chunks.

func Contains

func Contains[T comparable](s []T, v T) bool

Contains checks if slice contains element.

func Filter

func Filter[T any](s []T, fn func(T) bool) []T

Filter filters a slice.

func Find

func Find[T any](s []T, fn func(T) bool) (T, bool)

Find finds an element.

func First

func First[T any](s []T) (T, bool)

First returns the first element.

func Flatten

func Flatten[T any](s [][]T) []T

Flatten flattens nested slices.

func Intersperse

func Intersperse[T any](s []T, sep T) []T

Intersperse inserts sep between each element.

func Last

func Last[T any](s []T) (T, bool)

Last returns the last element.

func Map

func Map[T, U any](s []T, fn func(T) U) []U

Map applies a function to each element.

func Reverse

func Reverse[T any](s []T) []T

Reverse reverses a slice.

func Unique

func Unique[T comparable](s []T) []T

Unique returns unique elements.

Types

This section is empty.

Jump to

Keyboard shortcuts

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