Minimum (Arraylist function)

From m204wiki
Jump to navigation Jump to search

Get number of minimum item (Arraylist class)

Minimum returns the number of the Arraylist item that has the minimum numeric value after the application of a specified function to each item. The function that gets applied to each Arraylist item, which you identify in the argument to Minimum, must be a method that operates on the item type and returns a User Language intrinsic datatype (Float, String, Longstring, or Unicode) value.


%number = al:Minimum[( [itemFunction])]

Syntax terms

%number A numeric variable to return the item number of the item in the indicated Arraylist that has the minimum value after the argument method has been applied.
al An Arraylist object.
itemFunction A method value (a method name literal, a method variable, or even a method that returns a method value) for a method that operates on items of the type specified on the al declaration and that returns a numeric or string value.

As of Sirius Mods version 7.6, the special identity function, This, is the default itemFunction value for Maximum and Minimum. See "Using the This function as the Maximum parameter".

Usage notes

  • If the function applied by Minimum returns String or Unicode values, Minimum uses the collating sequence of EBCDIC or Unicode, respectively, to determine the number of the item that has the lowest value. If the function returns a numeric type, numeric comparisons are used.
  • If one or more Arraylist items have equal, minimum, values, Minimum returns the position of the item that appears closest to the beginning of the Arraylist.
  • The parameter for Minimum is a method value, not a User Language expression. That is, you cannot provide a function that itself has an argument (say, ToIntegerPower(2)) as the Minimum parameter. See the "Maximum and Minimum with local method" example, which shows a way to apply ToIntegerPower with the Maximum or Minimum method.
  • Minimum is available in Sirius Mods Version 7.3 and later.


In the following example, Minimum and Maximum use the special method, This, which simply returns the item value. The List function simplifies the construction of the Arraylist.

begin %alist is collection arraylist of string len 12 %alist = list('broken', 'br4ck', 'brown', 'Box', 'bumped') printText {~} is {%alist:minimum(this)} printText {~} is {%alist:maximum(this)} end

The result is:

%alist:minimum(this) is 1 %alist:maximum(this) is 4

See also