One-pass list statistics
The programmer’s goal is to compute the set of statistics (min, average, max) on a list in a single pass.
This isn’t hard if one is willing to use the low level primitives available in the language (iteration / fold) and do the bookkeeping manually. But the built-in min/max/average functions of most standard libraries are of no use.
The actual challenge is to build library pieces such that:
- Using them individually still is as easy as using the traditional
min/max/averagebuilt-ins. - They can trivially be combined into doing the one-pass computation described above.
If the compiler is sufficiently smart to turn the use of distinct functions into one computation, that’s worth noting as well.
