utils

package
v0.0.0-...-7d7b408 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CartesianProduct

func CartesianProduct[T any](elts []T, n int) iter.Seq[[]T]

CartesianProduct iterates over every combination of n items from the elts list. It will allocate "1 + len(elts) to the power of n" slices.

Internally it's using an array of indexes to iterate over every possible combination of positions in the elts list. It's using basic math to pass to the next possiblity by adding 1 to the lowest weight index and propagating the carry to a higher index, until all solutions have been interated over.

func Must

func Must[T any](v T, err error) T

Must takes any type of result and error. It panics if the error is non-nil. Otherwise, it returns the result.

func MustAtoInt

func MustAtoInt[T constraints.Integer](s string) T

MustAtoi converts a string to an integer. It panics if it fails.

func MustAtoi

func MustAtoi(s string) int

MustAtoi converts a string to an integer. It panics if it fails.

func MustNoErr

func MustNoErr(err error)

NoError panics if an error is present

Types

This section is empty.

Jump to

Keyboard shortcuts

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