Tinderbox v10 Icon

list.max()


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Data Type Returned: 

Operator First Added: 

Operator in Current Baseline: 

Operator Last Altered: 

 Property  [other Property type actions]

 List  [operators of similar scope]

 Data manipulation  [other Data manipulation operators]

 source context dependent

 v6.4.0

 Baseline

 As at baseline


Syntax note: Operators without any defined mandatory arguments may omit their empty closing parentheses


list.max()

list.max

The list.max() operator returns the largest item in a List- or Set-type list.

This is a replacement for/alternative to the max() operator.

Both the operators list.max() and list.min() use lexical comparison in most cases, but numeric comparison if the context is numeric (i.e. the reference is a Number-type attribute) and/or all list items are numbers. Thus:

$Width=("1;100;2").max; 

Since "Width" is numeric, max() will be return 100.

$Name=("1;100;2").max; 

Since the attribute "Name" is a string, max() will return 2.

If without a list, create one on the fly:

$MyMax = collect(all,$MyNumber).max; 
$MyMax = collect(descendants,$Modified).max; 

This allows export via ^value^:

^value(collect(descendants,$Modified).max)^ 

To use max() with a list of items that are attributes or expressions, use list():

Works: $MyNumber = list(4+2,9+6).max; (output: 15)

For more complex examples, where list items are action code expressions, it may be necessary to use eval() to wrap each list item expression e.g. list(eval(expressionA),eval(expressionB)).

Using lists of dates

When using Date-type data bear in mind that the defaults for an unset Date attribute is "never" and that "never" is treated as sorting always before (i.e. less than) any set date. So to use .min with dates, filter out the unset values, whereas with .max it is not needed:

$MyMax = collect_if(descendants,$Modified).max; 
$MyMin = collect_if(descendants,($Modified!="never"),$Modified).min; 

See also—notes linking to here: