Minimum (FloatNamedArraylist function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
mNo edit summary
Line 1: Line 1:
{{Template:FloatNamedArraylist:Minimum subtitle}}
{{Template:FloatNamedArraylist:Minimum subtitle}}


This function returns the number (subscript) of the FloatNamedArraylist item that
This function returns the number (subscript) of the <var>FloatNamedArraylist</var> item that
has the minimum value after the application of a specified function to each item.
has the minimum value after the application of a specified function to each item.
The function that gets applied to each FloatNamedArraylist item, which
The function that gets applied to each <var>FloatNamedArraylist</var> 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.


The system intrinsic classes are discussed in [[Intrinsic classes|"Intrinsic classes"]].
The system intrinsic classes are discussed in [[Intrinsic classes|"Intrinsic classes"]];
Local methods are discussed in [[??]] refid=localm..
local methods are discussed in [[Local and Common entities|"Local and Common entities"]].


Minimum is available in <var class="product">Sirius Mods</var> version 7.3 and later.
<var>Minimum</var> is available in <var class="product">Sirius Mods</var> version 7.3 and later.
==Syntax==
==Syntax==
{{Template:FloatNamedArraylist:Minimum syntax}}
{{Template:FloatNamedArraylist:Minimum syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%num</th>
<tr><th>%number</th>
<td>A numeric variable to contain the subscript number of the item in the indicated FloatNamedArraylist that has the minimum value after the argument function has been applied. </td></tr>
<td>A numeric variable to contain the subscript number of the item in <var class="term">fltNal</var>, the method <var>FloatNamedArraylist</var> object, that has the minimum value after the argument function has been applied. </td></tr>
<tr><th>%fnamrayl</th>
<tr><th>fltNal</th>
<td>A FloatNamedArraylist object. </td></tr>
<td>A <var>FloatNamedArraylist</var> object. </td></tr>
<tr><th>function</th>
<tr><th>itemFunction</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 objects of the type specified on the ''%fnamrayl'' 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 objects of the type specified on the <var class="term">fltNal</var> declaration and that returns a numeric or string value.


As of <var class="product">Sirius Mods</var> 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 <var class="product">Sirius Mods</var> version 7.6, the special identity function, <tt>This</tt>, is the default ''function'' value for the <var>Maximum</var> 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 <var class="term">itemFunction</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 37: Line 37:
"z" ranks lower than all the uppercase letters;
"z" ranks lower than all the uppercase letters;
and all letters rank lower than any number.
and all letters rank lower than any number.
<li>If one or more FloatNamedArraylist items have equal, minimum, values,
<li>If one or more <var>FloatNamedArraylist</var> items have equal, minimum, values,
Minimum returns the subscript of the item that appears closest to the beginning
<var>Minimum</var> returns the subscript of the item that appears closest to the beginning
of the FloatNamedArraylist.
of the <var>FloatNamedArraylist</var>.
<li>The [[Maximum (FloatNamedArraylist function)|Maximum]] function is the opposite of the Minimum function.
<li>The [[Maximum (FloatNamedArraylist 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><var class="term">itemFunction</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 Minimum parameter.
Example [[Maximum (Arraylist function)|"Maximum/Minimum with local method"]] shows a way to apply ToIntegerPower
Example [[Maximum (Arraylist function)|"Maximum/Minimum with local method"]] shows a way to apply <var>ToIntegerPower</var>
with Maximum or Minimum for an Arraylist.
with <var>Maximum</var> or <var>Minimum</var> for an <var>Arraylist</var>.
</ul>
</ul>
==Examples==
==Examples==
Line 51: Line 51:
The following request finds the minimum and maximum
The following request finds the minimum and maximum
differences between the two values that constitute each item
differences between the two values that constitute each item
in the FloatNamedArraylist.
in the <var>FloatNamedArraylist</var>.
A class method is the Minimum and Maximum function parameter.
A class method is the <var>Minimum</var> and <var>Maximum</var> function parameter.


For more examples of Minimum and Maximum for collections, see [[Collections#Finding collection maxima and minima, and sorting|"Finding collection maxima and minima, and sorting"]].
For more examples of <var>Minimum</var> and <var>Maximum</var> for collections, see [[Collections#Finding collection maxima and minima, and sorting|"Finding collection maxima and minima, and sorting"]].
<p class="code">b
<p class="code">b
class annual
class annual

Revision as of 12:45, 8 February 2012

Name of item with minimum value or minimum value of function applied to items (FloatNamedArraylist class)


This function returns the number (subscript) of the FloatNamedArraylist item that has the minimum value after the application of a specified function to each item. The function that gets applied to each FloatNamedArraylist 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 "Local and Common entities".

Minimum is available in Sirius Mods version 7.3 and later.

Syntax

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

Syntax terms

%number A numeric variable to contain the subscript number of the item in fltNal, the method FloatNamedArraylist object, that has the minimum value after the argument function has been applied.
fltNal A FloatNamedArraylist 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 objects of the type specified on the fltNal 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 itemFunction 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 FloatNamedArraylist items have equal, minimum, values, Minimum returns the subscript of the item that appears closest to the beginning of the FloatNamedArraylist.
  • The Maximum function is the opposite of the Minimum function.
  • itemFunction 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. Example "Maximum/Minimum with local method" shows a way to apply ToIntegerPower with Maximum or Minimum for an Arraylist.

Examples

The following request finds the minimum and maximum differences between the two values that constitute each item in the FloatNamedArraylist. A class method is the Minimum and Maximum function parameter.

For more examples of Minimum and Maximum for collections, see "Finding collection maxima and minima, and sorting".

b class annual public variable ybegin is float variable yend is float constructor newa (%beg is float, %end is float) function myprint is string len 24 function chg is float end public constructor newa (%beg is float, %end is float) %ybegin = %beg %yend = %end end constructor function myprint is string len 24 return 'ybegin=' with %ybegin with ', ' - with 'yend=' with %yend end function function chg is float %chg is float %chg = %yend - %ybegin return %chg end function End class %fann is floatnamedArraylist of object annual %fann = new %fann(12) = newa(621, 650) %fann(14) = newa(334, 343) %fann(15) = newa(288, 276) %fann(13) = newa(141, 182) %fann(11) = newa(131, 115) %i is float for %i from 1 to %fann:count print %fann:namebynumber(%i) With ': ' - With %fann:itembynumber(%i):myprint end for print 'item ' %fann:minimum(chg) ' has the minimum increase' print 'item ' %fann:maximum(chg) ' has the maximum increase' end

The result is.

11: ybegin=131, yend=115 12: ybegin=621, yend=650 13: ybegin=141, yend=182 14: ybegin=334, yend=343 15: ybegin=288, yend=276 item 11 has the minimum increase item 13 has the maximum increase

See also