Minimum (Arraylist function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
 
(41 intermediate revisions by 6 users not shown)
Line 1: Line 1:
<span style="font-size:120%; color:black"><b><section begin=dpl_desc/>Get item that has minimum value<section end=dpl_desc/></b></span>
{{Template:Arraylist:Minimum subtitle}}
[[Category:Arraylist methods|Minimum function]]
<var>Minimum</var> returns the number of the <var>Arraylist</var> item that has the minimum numeric value after the application of a specified function to each item.  The function that gets applied to each <var>Arraylist</var> item, which you identify in the argument to <var>Minimum</var>, must be a method that operates on the item type and returns a <var class="product">User Language</var> [[Intrinsic classes|intrinsic]] datatype (<var>Float</var>, <var>String</var>, <var>Longstring</var>, or <var>Unicode</var>) value.
<!--DPL?? Category:Arraylist methods|Minimum function: Get item that has minimum value-->
<p>
Minimum is a member of the [[Arraylist class]].
</p>


This function returns the number of the Arraylist item that has the minimum
==Syntax==
numeric value after the application of a specified function to each item.
{{Template:Arraylist:Minimum syntax}}
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]]".
===Syntax terms===
Local methods are discussed in [[??]] refid=localm..
<table class="syntaxTable">
<tr><th>%number</th>
<td>A numeric variable to return the item number of the item in the indicated <var>Arraylist</var> that has the minimum value after the argument method has been applied. </td></tr>


Minimum is available in ''Sirius Mods'' version 7.3 and later.
<tr><th>al</th>
===Syntax===
<td>An <var>Arraylist</var> object. </td></tr>
  %num = %arrayl:Minimum(function)
====Syntax Terms====
<dl>
<dt><i>%num</i>
<dd>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.
<dt><i>%arrayl</i>
<dd>An Arraylist object.
<dt><i>function</i>
<dd>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>,
<tr><th>itemFunction</th>
is the default ''function'' value for the Maximum and Minimum methods.
<td>A method value (a method name literal, a [[Method variables|method variable]], or even a method that returns a method value) for a method that operates on items of the type specified on the <var class="term">al</var> declaration and that returns a numeric or string value.<p>As of <var class="product">Sirius Mods</var> version 7.6, the special identity function, <var>This</var>, is the default <var class="term">itemFunction</var> value for <var>[[Maximum (Arraylist function)|Maximum]]</var> and <var>Minimum</var>. See [[Collections#Using the This function as the Maximum parameter|"Using the This function as the Maximum parameter"]].</p></td></tr>
See "[[Collections#Using the This function as the Maximum parameter|Using the This function as the Maximum parameter]]".
</table>


</dl>
==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 <var>String</var> or <var>Unicode</var> values, <var>Minimum</var> 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.
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 &ldquo;a&rdquo;;
the uppercase letters are ranked alphabetically and
the minimum uppercase letter is &ldquo;A&rdquo;;
&ldquo;z&rdquo; ranks lower than all the uppercase letters;
and all letters rank lower than any number.
<li>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.
<li>The [[Maximum (Arraylist function)|Maximum]] function is the opposite of the Minimum function.
<li>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, <tt>ToIntegerPower(2)</tt>) as the Minimum parameter.
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.
</ul>
===Examples===


In the following example, the Minimum and Maximum methods use the
<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>.
special method, <tt>This</tt>, which simply returns the item value.
The [[List (Arraylist function)|List]] function simplifies the construction of the
Arraylist.
<pre style="xmp">
    b
    %alist is collection arraylist of string len 12


    %alist = List('broken', 'br4ck', 'brown', 'Box', 'bumped')
<li>The parameter for <var>Minimum</var> is a method value, not a <var class="product">User Language</var> expression.  That is, you cannot provide a function that itself has an argument (say, <code>ToIntegerPower(2)</code>) as the <var>Minimum</var> parameter.  See the [[Maximum (Arraylist function)#Maximum and Minimum with local method|"Maximum and Minimum with local method"]] example, which shows a way to apply <var>[[ToIntegerPower and ToPower (Float functions)|ToIntegerPower]]</var> with the <var>Maximum</var> or <var>Minimum</var> method.


    PrintText {~} is {%alist:minimum(this)}
<li><var>Minimum</var> is available in <var class="product">[[Sirius Mods|Sirius Mods]]</var> Version 7.3 and later.
    PrintText {~} is {%alist:maximum(this)}
</ul>


    end
==Examples==
</pre>
In the following example, <var>Minimum</var> and <var>[[Maximum (Arraylist function)|Maximum]]</var> use the special method, <var>This</var>, which simply returns the item value.  The <var>[[List (Arraylist function)|List]]</var> function simplifies the construction of the <var>Arraylist</var>.
<p class="code">begin
  %alist is collection arraylist of string len 12
  %alist = [[List_(Arraylist_function)|list]]('broken', 'br4ck', 'brown', 'Box', 'bumped')
  [[PrintText statement|printText]] {~} is {%alist:minimum(this)}
  printText {~} is {%alist:maximum(this)}
end
</p>


The result is:
The result is:
<pre style="xmp">
<p class="output">%alist:minimum(this) is 1
    %alist:minimum(this) is 1
%alist:maximum(this) is 4
    %alist:maximum(this) is 4
</p>
</pre>
 
==See also==
<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> and <var>Maximum</var> examples, see the [[Maximum (Arraylist function)#Examples|Arraylist Maximum function examples]] and [[Collections#Finding collection maxima and minima, and sorting|"Finding collection maxima and minima, and sorting"]].
</ul>


As of ''Sirius Mods'' version 7.6, <tt>This</tt> is the default parameter for
{{Template:Arraylist:Minimum footer}}
Minimum 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 additional Minimum/Maximum 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]]".

Latest revision as of 16:15, 1 November 2012

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.

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

Examples

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