List Functions

list.average

<Numeric T> Double list.average(List(T) values)

Returns the average of the input values. If the list of values is empty, the operation yields a runtime error.

Parameters:

  • values - the input values (non-nullable, null elements not allowed).

Returns:

the average value.

list.containsAll

<Primitive T> Bool list.containsAll(List(T) list, List(T) values)

Checks whether all of the values are in the input list.

Parameters:

  • list - the input list (non-nullable, null elements allowed).
  • values - the list of values to check (non-nullable, null elements allowed).

Returns:

true if all of the values are in the input list, false otherwise.

list.containsAny

<Primitive T> Bool list.containsAny(List(T) list, List(T) values)

Checks whether any one of the values are in the input list.

Parameters:

  • list - the input list (non-nullable, null elements allowed).
  • values - the list of values to check (non-nullable, null elements allowed).

Returns:

true if any one of the values are in the input list, false otherwise.

list.difference

<Primitive T> List(T) list.difference(List(T) list1, List(T) list2)

Returns the difference of the first input list from the second input list by preserving the insertion order of values in the first list and removing duplicates.

Parameters:

  • list1 - the first list (non-nullable, null elements allowed).
  • list2 - the second list (non-nullable, null elements allowed).

Returns:

the difference of the first list from the second one where the order of values in the first list is preserved and duplicates are removed.

list.disjoint

<Primitive T> Bool list.disjoint(List(T) list1, List(T) list2)

Checks whether the two input lists are disjoint.

Parameters:

  • list1 - the first list (non-nullable, null elements allowed).
  • list2 - the second list (non-nullable, null elements allowed).

Returns:

true if the input lists are disjoint, false otherwise.

list.indicesOf

<Primitive T> List(Int32) list.indicesOf(List(T) list, T value)

Finds the indices at which the value is present in the input list.

Parameters:

  • list - the input list (non-nullable, null elements allowed).
  • value - the value (nullable).

Returns:

the list of the indices at which the value is present in the input list.

list.intersection

<Primitive T> List(T) list.intersection(List(T) list1, List(T) list2)

Returns the intersection of the two lists by preserving the order of values in the first input list and removing duplicates.

Parameters:

  • list1 - the first list (non-nullable, null elements allowed).
  • list2 - the second list (non-nullable, null elements allowed).

Returns:

the intersection of the two lists where the order of values in the first list is preserved and duplicates are removed.

list.lookup

<Primitive T, Primitive R> R list.lookup(T key, List(T) key_list, List(R) value_list)

Performs a dictionary lookup of the given key in the key list then returns the matching value from the value list, produces a runtime error if the key is not found.

Parameters:

  • key - the key (non-nullable).
  • key_list - the key list (non-nullable, null elements not allowed).
  • value_list - the value list (non-nullable, null elements allowed).

Returns:

the result of the dictionary lookup.

list.max

<Primitive T> T list.max(List(T) values)

Finds the maximum element of the input list, results in a runtime error if the list is empty.

Parameters:

  • values - the input list (non-nullable, null elements not allowed).

Returns:

the maximum element of the input list.

list.min

<Primitive T> T list.min(List(T) values)

Finds the minimum element of the input list, results in a runtime error if the list is empty.

Parameters:

  • values - the input list (non-nullable, null elements not allowed).

Returns:

the minimum element of the input list.

list.populationVariance

<Numeric T> Double list.populationVariance(List(T) values)

Returns the population variance of the input values. If the list of values is empty, the operation yields a runtime error.

Parameters:

  • values - the input list (non-nullable, null elements not allowed).

Returns:

the population variance of the elements of the input list.

list.reverse

<Primitive T> List(T) list.reverse(List(T) list)

Returns the reverse of the input list.

Parameters:

  • list - the input list (non-nullable, null elements allowed).

Returns:

the reversed list.

list.sampleVariance

<Numeric T> Double list.sampleVariance(List(T) values)

Returns the sample variance of the input values. If the length of the list of values is less than or equal to 1, the operation yields a runtime error.

Parameters:

  • values - the input list (non-nullable, null elements not allowed).

Returns:

the sample variance of the elements of the input list.

list.size

<Primitive T> Int32 list.size(List(T) list)

Returns the size of the input list.

Parameters:

  • list - the input list (non-nullable, null elements allowed).

Returns:

the size of the input list.

list.sort

<Primitive T> List(T) list.sort(List(T) list)

Returns the sorted version of the input list in ascending order.

Parameters:

  • list - the input list (non-nullable, null elements not allowed).

Returns:

the sorted list.

list.subList

<Primitive T> List(T) list.subList(List(T) list, Int32 startPosition, Int32 endPosition)

Returns a slice of the input list. Gives a runtime error if the start or the end position is outside of its valid range.

Parameters:

  • list - the input list (non-nullable, null elements allowed).
  • startPosition - the start position of the slice (inclusive, in the range [-size,size]). A negative value indicates a position relative to the end of the list (non-nullable).
  • endPosition - the end index of the slice (exclusive, in the range [-size,size]). A negative value indicates a position relative to the end of the list (non-nullable).

Returns:

a list representing the specified slice of the input.

list.sum

<Numeric T> Double list.sum(List(T) values)

Returns the sum of the input values. If the list of values is empty, the operation yields a runtime error.

Parameters:

  • values - the input list (non-nullable, null elements not allowed).

Returns:

the sum of the input values.

list.union

<Primitive T> List(T) list.union(List(T) list1, List(T) list2)

Returns the union of the two lists by preserving the order of values in the first list and removing duplicates.

Parameters:

  • list1 - the first list (non-nullable, null elements allowed).
  • list2 - the second list (non-nullable, null elements allowed).

Returns:

the union of the two lists where the order of values in the first list is preserved and duplicates are removed.