Skip to content

Instantly share code, notes, and snippets.

@Crilou
Created November 3, 2018 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Crilou/c107cfed020cde85d82ce0d7d2cca007 to your computer and use it in GitHub Desktop.
Save Crilou/c107cfed020cde85d82ce0d7d2cca007 to your computer and use it in GitHub Desktop.
Go=>Array+Slices
func whereismymin(Slice []float64) int {
var N int = len(Slice)
var min float64 = Slice[0]
var posmin int
for i:=1 ; i<N ; i++ {
if Slice[i]<min {
min = Slice[i]
posmin = i
}
}
return posmin
}
func whereismymax(Slice []float64) int {
var N int = len(Slice)
var max float64 = Slice[0]
var posmax int
for i:=1 ; i<N ; i++ {
if Slice[i]>max {
max = Slice[i]
posmax = i
}
}
return posmax
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment