Documentation
¶
Index ¶
- func Abs[N constraints.Number](n N) N
- func DivMod[N constraints.Integer](a, b N) (N, N)
- func Inf[N constraints.Number]() N
- func Max[V constraints.Ordered](seq iter.Seq[V]) V
- func Min[V constraints.Ordered](seq iter.Seq[V]) V
- func Product[V constraints.Integer](seq iter.Seq[V]) V
- func Sum[V constraints.Ordered](seq iter.Seq[V]) V
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DivMod ¶
func DivMod[N constraints.Integer](a, b N) (N, N)
DivMod returns the quotient and remainder of a division.
func Max ¶
func Max[V constraints.Ordered](seq iter.Seq[V]) V
Max returns the maximum value in the iterator.
Example ¶
package main
import (
"fmt"
"slices"
"github.com/elordeiro/goext/math"
)
func main() {
seq := slices.Values([]int{1, 2, 3, 4, 5})
fmt.Println(math.Max(seq))
}
Output: 5
func Min ¶
func Min[V constraints.Ordered](seq iter.Seq[V]) V
Min returns the minimum value in the iterator.
Example ¶
package main
import (
"fmt"
"slices"
"github.com/elordeiro/goext/math"
)
func main() {
seq := slices.Values([]int{1, 2, 3, 4, 5})
fmt.Println(math.Min(seq))
}
Output: 1
func Product ¶
func Product[V constraints.Integer](seq iter.Seq[V]) V
Product returns the product of all values in the iterator.
Example ¶
package main
import (
"fmt"
"slices"
"github.com/elordeiro/goext/math"
)
func main() {
seq := slices.Values([]int{1, 2, 3, 4, 5})
fmt.Println(math.Product(seq))
}
Output: 120
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.