util

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2025 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Find added in v0.0.3

func Find[A any](coll []*A, criteria func(i *A) bool) *A

Find returns the first element in a slice that satisfies the provided criteria function. If no element satisfies the criteria, nil is returned.

Type Parameters:

  • A: The type of elements in the slice

Parameters:

  • coll: The input slice to search
  • criteria: Function that determines whether an element matches

Returns:

  • *A: Pointer to the first matching element, or nil if no match is found

func Map

func Map[A any, B any](coll []A, mapper func(i A, index uint64) B) []B

Map applies a transformation function to each element of a slice and returns a new slice with the transformed values. This is a generic implementation of the map higher-order function.

Type Parameters:

  • A: The type of elements in the input slice
  • B: The type of elements in the output slice

Parameters:

  • coll: The input slice to transform
  • mapper: Function that transforms each element and receives the element's index

Returns:

  • []B: A new slice containing the transformed elements

Types

This section is empty.

Jump to

Keyboard shortcuts

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