package
Version:
v0.0.0-...-ea0ee21
Opens a new window with list of versions in this module.
Published: Feb 18, 2022
License: Apache-2.0
Opens a new window with license information.
Imports: 2
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
Package imath contains tools for signed integer math. It largely corresponds with go's built in `math` library for float64s
-
func Abs(n int) int
-
func Accumulate(f func(int, int) int, a []int) []int
-
func Clamp(n, low, high int) int
-
func Filter(f func(int) bool, a []int) []int
-
func Map(f func(int) int, a []int) []int
-
func Max(n int, a ...int) int
-
func Max2(a, b int) int
-
func Min(n int, a ...int) int
-
func Min2(a, b int) int
-
func Pow(base, exp int) int
-
func Product(a ...int) int
-
func RandSign() int
-
func Range(start, stop, step int) []int
-
func Reduce(f func(int, int) int, start int, a ...int) int
-
func Sign(n int) int
-
func Sum(a ...int) int
Abs returns the absolute value of n
Accumulate returns a slice B where B[i] = Reduce(f, a[:i+1]).
func Clamp(n, low, high int) int
Clamp takes an int n, returns low if n < low, high if n > high, and n otherwise.
Filter (f, a) returns a slice containing n for all n where f(n) == true
Map (f, a) returns a slice containing f(n) for every n in a
Max returns it's largest integer argument.
Max2 returns the largest of two integer arguments.
Min returns it's smallest integer argument.
Min2 returns the smallest of two integer arguments.
Pow is an efficent implementation of exponentiation by squaring.
Product returns the product of it's arguments. Product() is 1.
RandSign returns -1 or 1 at random, using the default Source of math/rand. This is NOT crypto-safe, at all.
func Range(start, stop, step int) []int
Range returns the slice of integers in [start, stop) obtained by repeatedly adding step to start.
Sign returns the sign of the operand. The sign of zero is zero.
Sum returns the sum of it's arguments. Sum() is 0
Source Files
¶
Directories
¶
Click to show internal directories.
Click to hide internal directories.