Created
September 4, 2018 01:55
-
-
Save bsolomon1124/f42ea7ef9b07c574c66f0ccf201211f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package variadic | |
// Platform-dependent largest and smallest values that int may take on | |
const ( | |
LargestInt = int(^uint(0) >> 1) | |
SmallestInt = -1 * int(^uint(0) >> 1) - 1 | |
) | |
func Min(a ...int) int { | |
min := LargestInt | |
for _, i := range a { | |
if i < min { | |
min = i | |
} | |
} | |
return min | |
} | |
func Max(a ...int) int { | |
max := SmallestInt | |
for _, i := range a { | |
if i > max { | |
max = i | |
} | |
} | |
return max | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment