Documentation
¶
Overview ¶
Package ints contains functions and constants to do with integers and generating sequences of integers.
Index ¶
Examples ¶
Constants ¶
const ( MaxUint = ^uint(0) MinUint = 0 MinInt = -MaxInt - 1 MaxInt = int(MaxUint >> 1) )
Variables ¶
This section is empty.
Functions ¶
func Max ¶
Max returns the maximum of all the given integers.
If no numbers are given 0 is returned.
func Min ¶
Min returns the minimum of all the given integers.
If no numbers are given 0 is returned.
func Ordinal ¶ added in v1.2.5
Ordinal gives you the input number in a rank/ordinal format.
Ordinal(3) -> 3rd. Straight from the "go-humanize" library: https://github.com/dustin/go-humanize.
Example ¶
Generates the ordinals for 1, 2 and 3.
fmt.Println(Ordinal(1), Ordinal(2), Ordinal(3))
Output: 1st 2nd 3rd
func Range ¶
Range generates an integer array with indices from start to end with the given step value.
Returns an empty array if step is equal to 0 or end is less than start and step is a positive number.
Example ¶
Counting down from 10 in intervals of 2.
The Range function is similar to the range function in Python.
r := Range(10, 0, -2) fmt.Println(r)
Output: [10 8 6 4 2 0]
Types ¶
This section is empty.