Re: Standard library praise and challenge

new topic     » goto parent     » topic index » view thread      » older message » newer message

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?

    1. Undefined results
    2. Die with an error message
    3. 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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu