summaryrefslogtreecommitdiff
path: root/factors/slices.go
blob: f2462cfbee994c0aed839122127f0c1558942365 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package factors

import "sort"

func sortUints(s []uint) []uint {
	sort.Slice(s, func(i, j int) bool { return s[i] < s[j] })
	return s
}

func maxUints(s []uint) uint {
	max := uint(0)
	for _, n := range s {
		if n > max {
			max = n
		}
	}
	return max
}

func contains[S ~[]E, E comparable](s S, e E) bool {
	for _, element := range s {
		if e == element {
			return true
		}
	}
	return false
}