utils

package
v0.0.0-...-a387ae0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs[T constraints.Integer | constraints.Float](x T) T

func All

func All[T any](f func(T) bool, s iter.Seq[T]) bool

func Any

func Any[T any](f func(T) bool, s iter.Seq[T]) bool

func Filter

func Filter[T any](f func(T) bool, s iter.Seq[T]) iter.Seq[T]

func Flatten2D

func Flatten2D[T any](grid [][]T) []T

func Map

func Map[In, Out any](f func(In) Out, s iter.Seq[In]) iter.Seq[Out]

func Reduce

func Reduce[Sum, V any](f func(Sum, V) Sum, sum Sum, s iter.Seq[V]) Sum

func Sum

func Sum[T constraints.Integer | constraints.Float](s iter.Seq[T]) T

func Tally

func Tally[T comparable](in []T) map[T]int

func Zip

func Zip[V1, V2 any](x iter.Seq[V1], y iter.Seq[V2]) iter.Seq[Zipped[V1, V2]]

Types

type Zipped

type Zipped[V1, V2 any] struct {
	V1  V1
	Ok1 bool // whether V1 is present (if not, it will be zero)
	V2  V2
	Ok2 bool // whether V2 is present (if not, it will be zero)
}

Jump to

Keyboard shortcuts

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