Moved logic of collapsing songs into albums to model package

(it should really be called domain.... maybe will rename it later)
This commit is contained in:
Deluan
2022-12-19 11:00:20 -05:00
committed by Deluan Quintão
parent e03ccb3166
commit 28e7371d93
13 changed files with 507 additions and 26 deletions
+31
View File
@@ -0,0 +1,31 @@
package number
import "golang.org/x/exp/constraints"
func Min[T constraints.Ordered](vs ...T) T {
if len(vs) == 0 {
var zero T
return zero
}
min := vs[0]
for _, v := range vs[1:] {
if v < min {
min = v
}
}
return min
}
func Max[T constraints.Ordered](vs ...T) T {
if len(vs) == 0 {
var zero T
return zero
}
max := vs[0]
for _, v := range vs[1:] {
if v > max {
max = v
}
}
return max
}