Re: Standard library praise and challenge
- Posted by SDPringle Sep 13, 2011
- 3277 views
I am seeing most people describing the functions max and min I wrote myself. I ask you though, what should happen when you pass an empty sequence?
- Undefined results
- Die with an error message
- Return the 'biggest value' or the 'smallest value'.
In the last option, though arguably impossible for real life numbers, the standard library set max({}) to be the smallest representable number, and min({}) the largest representable number. I never liked that behavior either and it is impossible to return the largest representable object. Well, there is a way (in C), but you wouldn't want such a monster to exist.
Shawn Pringle