Updating the statistics application
What we are going to do in this section is sort different datasets based on their mean value. As a result, the application is going to be able to read multiple files, which are going to be given as command line arguments to the utility—we are going to learn more about file I/O in Chapter 7, Telling a UNIX System What to Do.
We are going to create a structure that holds the statistical properties of each datafile, use a slice to store all such structures, and sort them based on the mean value of each dataset. The last functionality is going to be implemented using the sort.Interface
. Using a structure for keeping the important information organized is a common practice. Additionally, we are going to use the slices.Min()
and slices.Max()
functions for finding the minimum and the maximum value in a slice, respectively, which saves us from having to sort the slice.
Although such utilities look naïve at first, they can be the...