Adding primary files
This commit is contained in:
raul 2024-01-30 19:17:19 +01:00
parent fd93cb2923
commit 309cb67bda
2 changed files with 28 additions and 0 deletions

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module min-max
go 1.21.6

25
main.go Normal file
View File

@ -0,0 +1,25 @@
package main
// Returns either the largest value or the smallest value of an array
// TODO: Handle empty arrays without panicking
func min(arr []float64) (min float64) {
min = arr[0]
for _, v := range arr {
if v < min {
min = v
}
}
return min
}
func max(arr []float64) (max float64) {
max = arr[0]
for _, v := range arr {
if v > max {
max = v
}
}
return max
}