Minimum (Arraylist function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 1: Line 1:
{{Template:Arraylist:Minimum subtitle}}
{{Template:Arraylist:Minimum subtitle}}
[[Category:Arraylist methods|Minimum function]]
[[Category:Arraylist methods|Minimum function]]
<!--DPL?? Category:Arraylist methods|Minimum function: Get item that has minimum value-->
<!--DPL?? Category:Arraylist methods|<var>Minimum</var> function: Get item that has minimum value-->
<p>
<p>
Minimum is a member of the [[Arraylist class]].
<var>Minimum</var> is a member of the [[Arraylist class]].
</p>
</p>


Line 9: Line 9:
numeric value after the application of a specified function to each item.
numeric value after the application of a specified function to each item.
The function that gets applied to each Arraylist item, which
The function that gets applied to each Arraylist item, which
you identify in the argument to Minimum, must be a method
you identify in the argument to <var>Minimum</var>, must be a method
that operates on the item type and returns a User Language intrinsic
that operates on the item type and returns a User Language intrinsic
datatype (Float, String, Longstring, or Unicode) value.
datatype (Float, String, Longstring, or Unicode) value.
Line 16: Line 16:
Local methods are discussed in [[??]] refid=localm..
Local methods are discussed in [[??]] refid=localm..


Minimum is available in ''Sirius Mods'' version 7.3 and later.
<var>Minimum</var> is available in ''Sirius Mods'' version 7.3 and later.
==Syntax==
==Syntax==
{{Template:Arraylist:Minimum syntax}}
{{Template:Arraylist:Minimum syntax}}
Line 27: Line 27:
<tr><th><i>function</i></th>
<tr><th><i>function</i></th>
<td>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 ''%arrayl'' declaration and that returns a numeric or string value.
<td>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 ''%arrayl'' declaration and that returns a numeric or string value.
  As of ''Sirius Mods'' version 7.6, the special identity function, <tt>This</tt>, is the default ''function'' value for the Maximum and Minimum methods. See "[[Collections#Using the This function as the Maximum parameter|Using the This function as the Maximum parameter]]".</td></tr>
  As of ''Sirius Mods'' version 7.6, the special identity function, <tt>This</tt>, is the default ''function'' value for the Maximum and <var>Minimum</var> methods. See "[[Collections#Using the This function as the Maximum parameter|Using the This function as the Maximum parameter]]".</td></tr>
</table>
</table>
==Usage notes==
==Usage notes==
<ul>
<ul>
<li>If the function applied by Minimum returns string values, Minimum
<li>If the function applied by <var>Minimum</var> returns string values, <var>Minimum</var>
uses the decimal-equivalent value of the character bytes and determines
uses the decimal-equivalent value of the character bytes and determines
the number of the item that has the lowest value.
the number of the item that has the lowest value.
Line 41: Line 41:
and all letters rank lower than any number.
and all letters rank lower than any number.
<li>If one or more Arraylist items have equal, minimum, values,
<li>If one or more Arraylist items have equal, minimum, values,
Minimum returns the position of the item that appears closest to the beginning
<var>Minimum</var> returns the position of the item that appears closest to the beginning
of the Arraylist.
of the Arraylist.
<li>The [[Maximum (Arraylist function)|Maximum]] function is the opposite of the Minimum function.
<li>The [[Maximum (Arraylist function)|Maximum]] function is the opposite of the <var>Minimum</var> function.
<li>The parameter for Minimum is a method value, not a User Language expression.
<li>The parameter for <var>Minimum</var> is a method value, not a User Language expression.
That is, you cannot provide a function that itself has an argument
That is, you cannot provide a function that itself has an argument
(say, <tt>ToIntegerPower(2)</tt>) as the Minimum parameter.
(say, <tt>ToIntegerPower(2)</tt>) as the <var>Minimum</var> parameter.
See "[[Maximum (Arraylist function)#Maximum/Minimum with local method|example of Maximum/Minimum with local method]]", which shows a way to apply ToIntegerPower
See "[[Maximum (Arraylist function)#Maximum/Minimum with local method|example of Maximum/Minimum with local method]]", which shows a way to apply ToIntegerPower
with the Maximum or Minimum method.
with the Maximum or <var>Minimum</var> method.
</ul>
</ul>
==Examples==
==Examples==


In the following example, the Minimum and Maximum methods use the
In the following example, the <var>Minimum</var> and Maximum methods use the
special method, <tt>This</tt>, which simply returns the item value.
special method, <tt>This</tt>, which simply returns the item value.
The [[List (Arraylist function)|List]] function simplifies the construction of the
The [[List (Arraylist function)|List]] function simplifies the construction of the
Line 75: Line 75:


As of ''Sirius Mods'' version 7.6, <tt>This</tt> is the default parameter for
As of ''Sirius Mods'' version 7.6, <tt>This</tt> is the default parameter for
Minimum and Maximum.
<var>Minimum</var> and Maximum.
For more information about using <tt>This</tt>, see [[Collections#Using the This function as the Maximum parameter|Using the This function as the Maximum parameter]].
For more information about using <tt>This</tt>, see [[Collections#Using the This function as the Maximum parameter|Using the This function as the Maximum parameter]].
For additional Minimum/Maximum examples,
For additional <var>Minimum</var>/Maximum examples,
see the "[[Maximum (Arraylist function)#Examples|Arraylist Maximum function examples]]",
see the "[[Maximum (Arraylist function)#Examples|Arraylist Maximum function examples]]",
and also see
and also see
"[[Collections#Finding collection maxima and minima, and sorting|Finding collection maxima and minima, and sorting]]".
"[[Collections#Finding collection maxima and minima, and sorting|Finding collection maxima and minima, and sorting]]".

Revision as of 23:58, 19 January 2011

Get number of minimum item (Arraylist class)

Minimum is a member of the Arraylist class.

This function 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.

The system intrinsic classes are discussed in "Intrinsic classes". Local methods are discussed in ?? refid=localm..

Minimum is available in Sirius Mods version 7.3 and later.

Syntax

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

Syntax terms

%num A numeric variable to contain the item number of the item in the indicated Arraylist that has the minimum value after the argument method has been applied.
%arrayl An Arraylist object.
function 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 %arrayl declaration and that returns a numeric or string value. As of Sirius Mods version 7.6, the special identity function, This, is the default function value for the Maximum and Minimum methods. See "Using the This function as the Maximum parameter".

Usage notes

  • If the function applied by Minimum returns string values, Minimum uses the decimal-equivalent value of the character bytes and determines the number of the item that has the lowest value. Therefore, lowercase letters are ranked alphabetically and the minimum lowercase letter is "a"; the uppercase letters are ranked alphabetically and the minimum uppercase letter is "A"; "z" ranks lower than all the uppercase letters; and all letters rank lower than any number.
  • 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 Maximum function is the opposite of the Minimum function.
  • 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 "example of Maximum/Minimum with local method", which shows a way to apply ToIntegerPower with the Maximum or Minimum method.

Examples

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

    b
    %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

As of Sirius Mods version 7.6, This is the default parameter for Minimum and Maximum. For more information about using This, see Using the This function as the Maximum parameter. For additional Minimum/Maximum examples, see the "Arraylist Maximum function examples", and also see "Finding collection maxima and minima, and sorting".