Re: Standard library praise and challenge
- Posted by bill Sep 18, 2011
- 2922 views
Start with 'a' < {}.
This can only make sense if 'a' and {} are of the same type (object).
We have an order:
MIN_REAL,..,MAX_REAL,{},{MIN_REAL},..,{MAX_REAL},{ {} },..
Max is declared to be max(object a) and returns the maximum atom of the flattened list.
Given this max({}) is an error as is max({}} and max({ {},{} }) even though they are valid lists.
A general form of max() would be max(sequence S) where S is a list of objects (possibly empty).
An empty list would then return an empty list; a non-empty list would return a list containing its maximum element. Min() would work similarly.
Examples:
max({}) ==> {} max({ {} }) ==> { {} } max({ {},{} } ==> { {} } max({"head","tail"} ==> {"tail"} max("head") ==> ('h')
That, I hope covers it.