Maximal-/Minimal-Value Expression Functions
-
min andmax are supported in update expressions. -
Regarding the use of the
min andmax functions with arrays, note that in the current release this is restricted to the web APIs.
max
The
Compare Simple Values
max(a, b)
When attr1+attr1
or attr1==attr2
).
For example, given "max(attr1, attr2+attr3)"
- Strings are compared using lexicographic string comparison.
- Numeric values of different data types are compared using numeric promotion.
The type of the return value is that of the largest data type from among the compared values.
For example,
"max(1.0, 9)
returns 9.0 (double). - Boolean values are implicitly converted to numbers to allow comparison —
true
= 1 andfalse
= 0. However, the data type of the function's return value in the case of a Boolean operand is the winning data type — i.e., the original data type of the returned value. For example,"max(1==1, 1==2)"
and"max(1==1, 0)"
both returntrue
(Boolean), but"max(1==1, 3)"
returns 3 (integer).
Compare Array Elements
max(ARRAY)
When ARRAY
), it returns the highest (maximal) value from among the values of all elements of the specified array or array slice.
The parameter can be the name of an array attribute (ARRAY-ATTRIBUTE
), or a slice of an array attribute that indicates the zero-based index range of the array elements to compare (ARRAY-ATTRIBUTE[istart..
iend
]
For example, for a "max(myArray)"
returns 13 and "max(myArray[2..3])"
min
The
Compare Simple Values
min(a, b)
When attr1+attr1
or attr1==attr2
).
For example, given "min(attr1, attr2+attr3)"
- Strings are compared using lexicographic string comparison.
- Numeric values of different data types are compared using numeric promotion.
The type of the return value is that of the largest data type from among the compared values.
For example,
"min(1, 9.0)
returns 1.0 (double). - Boolean values are implicitly converted to numbers to allow comparison —
true
= 1 andfalse
= 0. However, the data type of the function's return value in the case of a Boolean operand is the winning data type — i.e., the original data type of the returned value. For example,"min(1==1, 1==2)"
and"min(1==2, 1)"
both returnfalse
(Boolean), but"min(1==1, 0)"
returns 0 (integer).
Compare Array Elements
min(ARRAY)
When ARRAY
), it returns the lowest (minimal) value from among the values of all elements of the specified array or array slice.
The parameter can be the name of an array attribute (ARRAY-ATTRIBUTE
), or a slice of an array attribute that indicates the zero-based index range of the array elements to compare (ARRAY-ATTRIBUTE[istart..
iend
]
For example, for a "min(myArray)"
returns 1 and "min(myArray[1..2])"