package mathutilimport ()// Min compare two value and return max valuefunc [ comdef.Number](, ) {if < {return }return}// Max compare two value and return max valuefunc [ comdef.Number](, ) {if > {return }return}// SwapMin compare and always return [min, max] valuefunc [ comdef.Number](, ) (, ) {if < {return , }return , }// SwapMax compare and always return [max, min] valuefunc [ comdef.Number](, ) (, ) {if > {return , }return , }// MaxInt compare and return max valuefunc (, int) int {if > {return }return}// SwapMaxInt compare and return max, min valuefunc (, int) (int, int) {if > {return , }return , }// MaxI64 compare and return max valuefunc (, int64) int64 {if > {return }return}// SwapMaxI64 compare and return max, min valuefunc (, int64) (int64, int64) {if > {return , }return , }// MaxFloat compare and return max valuefunc (, float64) float64 {returnmath.Max(, )}// OrElse return default value on val is zero, else return valfunc [ comdef.Number](, ) {returnZeroOr(, )}// ZeroOr return default value on val is zero, else return valfunc [ comdef.Number](, ) {if != 0 {return }return}// LessOr return val on val < max, else return default value.//// Example://// LessOr(11, 10, 1) // 1// LessOr(2, 10, 1) // 2// LessOr(10, 10, 1) // 1func [ comdef.Number](, , ) {if < {return }return}// LteOr return val on val <= max, else return default value.//// Example://// LteOr(11, 10, 1) // 11// LteOr(2, 10, 1) // 2// LteOr(10, 10, 1) // 10func [ comdef.Number](, , ) {if <= {return }return}// GreaterOr return val on val > max, else return default value.//// Example://// GreaterOr(23, 0, 2) // 23// GreaterOr(0, 0, 2) // 2func [ comdef.Number](, , ) {if > {return }return}// GteOr return val on val >= max, else return default value.//// Example://// GteOr(23, 0, 2) // 23// GteOr(0, 0, 2) // 0func [ comdef.Number](, , ) {if >= {return }return}
The pages are generated with Goldsv0.8.4. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.