Minimum (Arraylist function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (match syntax diagram to template and fix tags)
m (review and edit for better wording)
Line 19: Line 19:
==Usage notes==
==Usage notes==
<ul>
<ul>
<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 the number of the item that has the lowest value.
<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 the number of the item that has the lowest value. Lowercase letters are first ranked alphabetically, then upper case letters, also ranked alphabetically, followed by the numbers; ie: <code>'a'..'z','A'..'Z',0..9</code>.
Therefore, lowercase letters are ranked alphabetically and the minimum lowercase letter is <code>'a'</code>; the uppercase letters are ranked alphabetically and the minimum uppercase letter is <code>'A'</code>;
<code>'z'</code> ranks lower than all the uppercase letters; and all letters rank lower than any number.
<li>If one or more <var>Arraylist</var> items have equal, minimum, values, <var>Minimum</var> returns the position of the item that appears closest to the beginning of the <var>Arraylist</var>.
<li>If one or more <var>Arraylist</var> items have equal, minimum, values, <var>Minimum</var> returns the position of the item that appears closest to the beginning of the <var>Arraylist</var>.
<li>The <var>[[Maximum (Arraylist function)|Maximum]]</var> function is the opposite of the <var>Minimum</var> function.
<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 (say, <code><var>[[ToIntegerPower and ToPower (Float functions)|ToIntegerPower]]</var>(2)</code>) 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 <var>[[ToIntegerPower and ToPower (Float functions)|ToIntegerPower]]</var> with the Maximum or <var>Minimum</var> method.
<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 (say, <code><var>[[ToIntegerPower and ToPower (Float functions)|ToIntegerPower]]</var>(2)</code>) 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 <var>[[ToIntegerPower and ToPower (Float functions)|ToIntegerPower]]</var> with the Maximum or <var>Minimum</var> method.
<li><var>Minimum</var> is available in <var class="product">Sirius Mods</var> version 7.3 and later.
<li><var>Minimum</var> is available in <var class="product">Sirius Mods</var> version 7.3 and later.
Line 51: Line 48:


==See also==
==See also==
<ul><li>For additional <var>Minimum</var> /  <var>[[Maximum (Arraylist function)|Maximum]]</var> examples, see the "[[Maximum (Arraylist function)#Examples|Arraylist Maximum function examples]]", and also see "[[Collections#Finding collection maxima and minima, and sorting|Finding collection maxima and minima, and sorting]]".</ul>
<ul><li>The <var>[[Maximum (Arraylist function)|Maximum]]</var> function is the opposite of the <var>Minimum</var> function.<li>For additional <var>Minimum</var> /  <var>[[Maximum (Arraylist function)|Maximum]]</var> examples, see the "[[Maximum (Arraylist function)#Examples|Arraylist Maximum function examples]]", and also see "[[Collections#Finding collection maxima and minima, and sorting|Finding collection maxima and minima, and sorting]]".</ul>
{{Template:Arraylist:Minimum footer}}
{{Template:Arraylist:Minimum footer}}

Revision as of 02:20, 31 January 2011

Get number of minimum item (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..

Syntax

%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.
method 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 method value for Maximum and Minimum. 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. Lowercase letters are first ranked alphabetically, then upper case letters, also ranked alphabetically, followed by the numbers; ie: 'a'..'z','A'..'Z',0..9.
  • 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 "example of Maximum/Minimum with local method", which shows a way to apply ToIntegerPower with the Maximum or Minimum method.
  • Minimum is available in Sirius Mods version 7.3 and later.

Examples

  1. 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

    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.

See also