max, maxi, maxf

Synopsis

max

set max(set)
set max(set, int)

maxi

int maxi(set)

maxf

float maxf(set)

Description

The max command, in its first form returns a singleton set consisting of the largest number in the parameter set. In the second form, the returned set is not a singleton, but contains X largest numbers from the input set, where X is the second parameter.

This command only considers numeric members of the input set, or strings that can be interpreted as a number. All other members of the set are ignored. If the set contains no numbers and no strings that can be interpreted as a number, an empty set is returned.

The maxi and maxf commands operate in essentially the same way as max, except that they return an int or a float respectively. The greatest found number in the provided set is cast to the appropriate return type, and rounded if necessary.

Example

>> numbers= { 1,2,3,4,5,345,23451,24,1234,5616,1,3451,41,64,134,1,34,6134,7665,783}
>> strings = {"aaa", "bbb", "ccc", "ddd", "eee", "fff"}
>> floats ={231.234, 123.62341, 8456.2361, 4444444.111}
>> numStrings = {"2341.342", "11", "999999", "3e10"}
>> max (numbers)
23451
>> max (numbers, 2)
23451
7665
>> {} == max (strings)
true
>> max (numStrings,2)
3e10
999999
>> max (numbers + strings + floats + numStrings, 8)
3e10
4444444.0
999999
23451
8456.236
7665
6134
5616
>> max (numbers + strings + floats + numStrings, 0)

See Also

min