Documentation ¶
Overview ¶
Package billsutil contains a set of miscellaneaous utilities Bill finds useful In particular it contains utilties for operating on slices using common functional idioms
Index ¶
- func Abs(n int) int
- func AllInt(vs []int, f func(int) bool) bool
- func FindInt(vs []int, val int) []int
- func IsPrime(p int) bool
- func MapChar(vs string, f func(rune) rune) string
- func MapInt(vs []int, f func(int) int) []int
- func Max(i, j int) int
- func Min(i, j int) int
- func MinArray(js []int) int
- func ReduceInt(vs []int, f func(int, int) int) int
- func Reverse(s sort.Interface)
- func ReverseInt(is []int) []int
- func ReverseStr(str string) string
- func TimeIt(start time.Time, name string) time.Duration
- func TimedFunc(fn func()) time.Duration
- type RuneSlice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllInt ¶
AllInt returns true if all of the ints in the slice satisfy the predicate f. The slice must be non empty
func FindInt ¶
FindInt returns a slice of all positions of val in the slice vs. If there are no occurrences, an empty slice is returned.
func MapChar ¶
MapChar returns a new slice containing the results of applying the function f to each string in the original slice.
func MapInt ¶
MapInt returns a new slice containing the results of applying the function f to each int in the original slice.
func ReduceInt ¶
ReduceInt returns the result of a pairwise application of the function through the slice The input slice must be at least length 2
func Reverse ¶
Reverse reverses any sortable collection and is very efficient. Note that it reverse in place, so it modifies the slice passed in This is the implementation of the stringutil.Reverse example at https://github.com/golang/example
func ReverseInt ¶
ReverseInt is a convenience method for reversing Int slices It makes a copy of the input to avoid mutating it.
func ReverseStr ¶
ReverseStr is a convenience method for reversing strings