Initial commit
implemented the game of life variation with hexagonal grid
This commit is contained in:
37
math/comp.go
Normal file
37
math/comp.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package math
|
||||
|
||||
func Max[T SignedNumber](nLst ...T) T {
|
||||
switch len(nLst) {
|
||||
case 0:
|
||||
var zeroT T
|
||||
return zeroT
|
||||
case 1:
|
||||
return nLst[0]
|
||||
default:
|
||||
m := nLst[0]
|
||||
for _, n := range nLst[1:] {
|
||||
if m < n {
|
||||
m = n
|
||||
}
|
||||
}
|
||||
return m
|
||||
}
|
||||
}
|
||||
|
||||
func Min[T SignedNumber](nLst ...T) T {
|
||||
switch len(nLst) {
|
||||
case 0:
|
||||
var zeroT T
|
||||
return zeroT
|
||||
case 1:
|
||||
return nLst[0]
|
||||
default:
|
||||
m := nLst[0]
|
||||
for _, n := range nLst[1:] {
|
||||
if m > n {
|
||||
m = n
|
||||
}
|
||||
}
|
||||
return m
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user