4.3.2.4. List functions
The following functions support list operations.
In FEEL, the index of the first element in a list is 1. The index of the last element in a list can be identified as -1.
- list contains( list, element )
Returns
trueif the list contains the element.Expand 表4.28 Parameters Parameter Type listlistelementAny type, including null
Example
list contains( [1,2,3], 2 ) = true- count( list )
Counts the elements in the list.
Expand 表4.29 Parameters Parameter Type listlistExamples
count( [1,2,3] ) = 3 count( [] ) = 0 count( [1,[2,3]] ) = 2- min( list )
Returns the minimum comparable element in the list.
Expand 表4.30 Parameters Parameter Type listlistAlternative signature
min( e1, e2, ..., eN )Examples
min( [1,2,3] ) = 1 min( 1 ) = 1 min( [1] ) = 1- max( list )
Returns the maximum comparable element in the list.
Expand 表4.31 Parameters Parameter Type listlistAlternative signature
max( e1, e2, ..., eN )Examples
max( 1,2,3 ) = 3 max( [] ) = null- sum( list )
Returns the sum of the numbers in the list.
Expand 表4.32 Parameters Parameter Type listlistofnumberelementsAlternative signature
sum( n1, n2, ..., nN )Examples
sum( [1,2,3] ) = 6 sum( 1,2,3 ) = 6 sum( 1 ) = 1 sum( [] ) = null- mean( list )
Calculates the average (arithmetic mean) of the elements in the list.
Expand 表4.33 Parameters Parameter Type listlistofnumberelementsAlternative signature
mean( n1, n2, ..., nN )Examples
mean( [1,2,3] ) = 2 mean( 1,2,3 ) = 2 mean( 1 ) = 1 mean( [] ) = null- all( list )
Returns
trueif all elements in the list are true.Expand 表4.34 Parameters Parameter Type listlistofbooleanelementsAlternative signature
all( b1, b2, ..., bN )Examples
all( [false,null,true] ) = false all( true ) = true all( [true] ) = true all( [] ) = true all( 0 ) = null- any( list )
Returns
trueif any element in the list is true.Expand 表4.35 Parameters Parameter Type listlistofbooleanelementsAlternative signature
any( b1, b2, ..., bN )Examples
any( [false,null,true] ) = true any( false ) = false any( [] ) = false any( 0 ) = null- sublist( list, start position, length? )
Returns the sublist from the start position, limited to the length elements.
Expand 表4.36 Parameters Parameter Type listliststart positionnumberlength(Optional)numberExample
sublist( [4,5,6], 1, 2 ) = [4,5]- append( list, item )
Creates a list that is appended to the item or items.
Expand 表4.37 Parameters Parameter Type listlistitemAny type
Example
append( [1], 2, 3 ) = [1,2,3]- concatenate( list )
Creates a list that is the result of the concatenated lists.
Expand 表4.38 Parameters Parameter Type listlistExample
concatenate( [1,2],[3] ) = [1,2,3]- insert before( list, position, newItem )
Creates a list with the
newIteminserted at the specified position.Expand 表4.39 Parameters Parameter Type listlistpositionnumbernewItemAny type
Example
insert before( [1,3],1,2 ) = [2,1,3]- remove( list, position )
Creates a list with the removed element excluded from the specified position.
Expand 表4.40 Parameters Parameter Type listlistpositionnumberExample
remove( [1,2,3], 2 ) = [1,3]- reverse( list )
Returns a reversed list.
Expand 表4.41 Parameters Parameter Type listlistExample
reverse( [1,2,3] ) = [3,2,1]- index of( list, match )
Returns indexes matching the element.
Parameters
-
listof typelist -
matchof any type
Expand 表4.42 Parameters Parameter Type listlistmatchAny type
Example
index of( [1,2,3,2],2 ) = [2,4]-
- union( list )
Returns a list of all the elements from multiple lists and excludes duplicates.
Expand 表4.43 Parameters Parameter Type listlistExample
union( [1,2],[2,3] ) = [1,2,3]- distinct values( list )
Returns a list of elements from a single list and excludes duplicates.
Expand 表4.44 Parameters Parameter Type listlistExample
distinct values( [1,2,3,2,1] ) = [1,2,3]- flatten( list )
Returns a flattened list.
Expand 表4.45 Parameters Parameter Type listlistExample
flatten( [[1,2],[[3]], 4] ) = [1,2,3,4]- product( list )
Returns the product of the numbers in the list.
Expand 表4.46 Parameters Parameter Type listlistofnumberelementsAlternative signature
product( n1, n2, ..., nN )Examples
product( [2, 3, 4] ) = 24 product( 2, 3, 4 ) = 24- median( list )
Returns the median of the numbers in the list. If the number of elements is odd, the result is the middle element. If the number of elements is even, the result is the average of the two middle elements.
Expand 表4.47 Parameters Parameter Type listlistofnumberelementsAlternative signature
median( n1, n2, ..., nN )Examples
median( 8, 2, 5, 3, 4 ) = 4 median( [6, 1, 2, 3] ) = 2.5 median( [ ] ) = null- stddev( list )
Returns the standard deviation of the numbers in the list.
Expand 表4.48 Parameters Parameter Type listlistofnumberelementsAlternative signature
stddev( n1, n2, ..., nN )Examples
stddev( 2, 4, 7, 5 ) = 2.081665999466132735282297706979931 stddev( [47] ) = null stddev( 47 ) = null stddev( [ ] ) = null- mode( list )
Returns the mode of the numbers in the list. If multiple elements are returned, the numbers are sorted in ascending order.
Expand 表4.49 Parameters Parameter Type listlistofnumberelementsAlternative signature
mode( n1, n2, ..., nN )Examples
mode( 6, 3, 9, 6, 6 ) = [6] mode( [6, 1, 9, 6, 1] ) = [1, 6] mode( [ ] ) = [ ]