MinimumItem (Arraylist function)

From m204wiki
Revision as of 16:46, 27 July 2012 by JAL2 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Get item that has minimum value (Arraylist class)

[Introduced in Sirius Mods 7.8]


MinimumItem is related to the Minimum Arraylist method, which returns the number or name of the item that has the minimum value in an Arraylist.

Syntax

%item = al:MinimumItem[( [itemFunction])]

Syntax terms

%item An Arraylist item of the same type as the al object.
al An Arraylist object.
itemFunction A function that operates on the type of the items in the Arraylist. It may be a local method or method variable or a class member (Variable, Property), and it must return an intrinsic value. The default itemFunction value is the special identity function, This, which simply returns the item value.

Usage notes

  • The optional itemFunction parameter lets you further manipulate the Arraylist item values before performing the MinimumItem method's item evaluation. The itemFunction default (identity function This) fails against non-intrinsic values, however. If your Arraylist items are not intrinsic values, you must specify an itemFunction function that can map the item values to intrinsic values.

Examples

For the ArrayList %al whose items are the odd integers between 10 and 0, MinimumItem returns the value of the item that has the minimum value, while Minimum returns the index (item number) of that item:

b %al is arraylist of float %al = list(9,7,5,3,1) printText {~=%al:minimumItem} printText {~=%al:minimum} end

The result is:

%al:minimumItem=1 %al:minimum=5

See also