util

package
v0.0.0-...-4fb4631 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs[T constraints.Integer](value T) T

Abs returns the absolute value of an integer

func Filter

func Filter[T any](ts []T, f func(T) bool) []T

Filter a list, return only elements that return true for the compare method.

func Map

func Map[T, U any](ts []T, f func(T) U) []U

Map returns a list of elements, where the new element is the result of running the passed function.

func ParseInt

func ParseInt(value string) int

ParseInt parses an integer, panics if an error happened.

func ParseUint64

func ParseUint64(value string) uint64

ParseUint64 parses an integer, panics if an error happened.

func ParseUint8

func ParseUint8(value string) uint8

ParseUint8 parses an integer, panics if an error happened.

Types

type Point

type Point struct {
	X, Y int
}

func (Point) DistanceTo

func (p Point) DistanceTo(other *Point) int

DistanceTo returns the manhattan distance between two points.

func (Point) String

func (p Point) String() string

String returns a string representation of the point.

Jump to

Keyboard shortcuts

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