These exercises let you experiment with writing functions of your own.
-
Write a function called subtract that takes in two int parameters and returns an int. Call this function from main with several values and print out the result.
-
Write a function named minMax that takes in 0 or more int values and returns three results: the smallest number, the largest number, and an error. If no values are passed to minMax, return an error using
errors.New. Otherwise, the returned error should be nil. Call it from main three ways: with no arguments, with several arguments, and with an []int. -
Write a function
splitthat accepts a string and a separator and returns the nonempty parts. Review its parameter handling, return values, and control flow, and explain how each choice improves clarity.