This version is out of date, covering development from v7.0.0 to v7.5.6. It is maintained here only for inbound reference links from elsewhere. It is no longer actively updated.

Jump to the current version of aTbRef

Tinderbox 7 Icon

List/set.min


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Operator First Added: 

Operator Altered: 

 Property   [other Property type actions]

 List   [operators of similar scope]

 Data manipulation   [other Data manipulation operators]

 Baseline

 


List/Set.min

The List/Set.min operator returns the smallest item in a List or Set data type attribute.

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

Both the operators List/Set.min and List/Set.max 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=("100;2;70").min 

Since "Width" is numeric, min() will be return 2.

$Name=("100;2;70").min 

Since the attribute "Name" is a string, .min will return 100.

If you don't have a set, create one on the fly:

$MyMin = collect_if(all,$MyNum>0,$MyNum).min 

$MyMin = collect(descendants,$Modified).min 

This allows export via ^value^:

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

When using Date-type data bear in mind that the unset Date default is "never" and that "never' is always before (i.e. less than) any set date. So to use .min with dates, filter out the unset values:

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

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

Works: $MyNum = list(4+2,9+6).min (output: 6)

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)).