Re: Standard library praise and challenge

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

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.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu