MinimumItem (Arraylist function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Template:Arraylist:MinimumItem subtitle}}
{{Template:Arraylist:MinimumItem subtitle}}


<var>MinimumItem</var> is related to the <var>[[Minimum (Arraylist function)|Minimum]]</var> <var>Arraylist</var> method, which return the number or name of the item that has the minimum value in an <var>Arraylist</var>.
<var>MinimumItem</var> is related to the <var>[[Minimum (Arraylist function)|Minimum]]</var> <var>Arraylist</var> method, which returns the number or name of the item that has the minimum value in an <var>Arraylist</var>.


==Syntax==
==Syntax==
Line 14: Line 14:
<td>An <var>Arraylist</var> object.</td></tr>
<td>An <var>Arraylist</var> object.</td></tr>


<tr><th>method</th>
<tr><th>itemFunction</th>
<td>A function that operates on the type of the items in the <var>Arraylist</var>. It may be a [[Local and Common entities|local method]] or [[Method variables|method variable]] or a class member (<var>Variable</var>, <var>Property</var>), and it must return an [[Intrinsic classes|intrinsic]] (probably <var>Float</var>) value. The default <var class="term">method</var> value is the special identity function, <var>[[Collections#Using the This function as the Maximum parameter|This]]</var>, which simply returns the item value.</td></tr>
<td>A function that operates on the type of the items in the <var>Arraylist</var>. It may be a [[Local and Common entities|local method]] or [[Method variables|method variable]] or a class member (<var>Variable</var>, <var>Property</var>), and it must return an [[Intrinsic classes|intrinsic]] value. The default <var class="term">itemFunction</var> value is the special identity function, <var>[[Collections#Using the This function as the Maximum parameter|This]]</var>, which simply returns the item value.</td></tr>
</table>
</table>


==Usage notes==
==Usage notes==
<ul>
<ul>
<li>The optional <var class="term">method</var> parameter lets you further manipulate the <var>Arraylist</var> item values before performing the  
<li>The optional <var class="term">itemFunction</var> parameter lets you further manipulate the <var>Arraylist</var> item values before performing the <var>MinimumItem</var> method's item evaluation.
<var>MinimumItem</var> method's item matching.
The <var class="term">itemFunction</var> default (identity function <var>This</var>) fails against non-intrinsic values, however. If your <var>Arraylist</var> items are <i>not</i> intrinsic values, you must specify an <var class="term">itemFunction</var> function that can map the item values to intrinsic values.
If your <var>Arraylist</var> items are not intrinsic values, you must specify a <var class="term">method</var> function that can map the item values to intrinsic values or the method will fail.
</ul>
</ul>


==Examples==
==Examples==
For the <var>ArrayList</var> <code>%al</code> whose items are the odd integers between 0 and 10, <code>%al:minItem</code> returns <code>1</code>.
For the <var>ArrayList</var> <code>%al</code> whose items are the odd integers between 10 and 0, <var>MinimumItem</var> returns the value of the item that has the minimum value, while <var>Minimum</var> returns the index (item number) of that item:
<p class="code">b                                 
                                   
%al  is arraylist of float         
%al = list(9,7,5,3,1)
 
printText {~=%al:minimumItem}
printText {~=%al:minimum}
end </p>
 
The result is:
<p class="output">%al:minimumItem=1  
%al:minimum=5 </p>


==See also==
==See also==
{{Template:Arraylist:MinimumItem footer}}
{{Template:Arraylist:MinimumItem footer}}

Latest revision as of 16:46, 27 July 2012

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