Minimum (FloatNamedArraylist function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Created page with "<span style="font-size:120%; color:black"><b><section begin=dpl_desc/>Get item that has minimum value<section end=dpl_desc/></b></span> [[Category:FloatNamedArraylist methods|Min...")
 
mNo edit summary
 
(24 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:FloatNamedArraylist:Minimum subtitle}}
[[Category:FloatNamedArraylist methods|Minimum function]]
<!--DPL?? Category:FloatNamedArraylist methods|Minimum function: Get item that has minimum value-->
<var>Minimum</var> returns the (numeric) name of the <var>FloatNamedArraylist</var> item that has the minimum value as returned by a specified function. The function applied to each <var>FloatNamedArraylist</var> item, which you specify with the required <var class="term">itemFunction</var> argument, 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>, or <var>Unicode</var>) value.
<p>
Minimum is a member of the [[FloatNamedArraylist class]].
<var>Minimum</var> is available in <var class="product">Sirius Mods</var> version 7.3 and later.
</p>
 
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 [[??]] refid=localm..
 
Minimum is available in ''Sirius Mods'' version 7.3 and later.
==Syntax==
==Syntax==
  %num = %fnamrayl:Minimum(function)
{{Template:FloatNamedArraylist:Minimum syntax}}
===Syntax Terms===
<dl>
===Syntax terms===
<dt><i>%num</i>
<table class="syntaxTable">
<dd>A numeric variable to contain the subscript number of the
<tr><th>%number</th>
item in the indicated FloatNamedArraylist that has the minimum value
<td>A numeric variable to contain the name of the item in <var class="term">fltNal</var>, the method <var>FloatNamedArraylist</var> object, that has the minimum value as returned by the argument function. </td></tr>
after the argument function has been applied.
<tr><th>fltNal</th>
<dt><i>%fnamrayl</i>
<td>A <var>FloatNamedArraylist</var> object. </td></tr>
<dd>A FloatNamedArraylist object.
<tr><th>itemFunction</th>
<dt><i>function</i>
<td>A method value (a method name literal, a method variable, or even a method that returns a method value) that operates on objects of the type specified on the <var class="term">fltNal</var> declaration and that returns an intrinsic value.
<dd>A method value (a method name literal, a method variable,
or even a method that returns a method value) for a method
As of <var class="product">Sirius Mods</var> version 7.6, the special identity function, <tt>This</tt>, is the default <var class="term">itemFunction</var> 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>
that operates on objects of the type specified on the ''%fnamrayl''
</table>
declaration and that returns a numeric or string value.
 
==Usage notes==
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]].
 
</dl>
==Usage Notes==
<ul>
<ul>
<li>If the function applied by Minimum returns string values, Minimum
<li>If <var class="term">itemFunction</var> returns <var>String</var> or <var>Unicode</var> values, <var>Minimum</var> uses the collating sequence of EBCDIC or Unicode, respectively, to determine which item that has the lowest value.
uses the decimal-equivalent value of the character bytes and determines
If <var class="term">itemFunction</var> returns a numeric type, numeric comparisons are used. See the [[Minimum (NamedArraylist function)#Examples|"example"]] for the <var>NamedArraylist</var> <var>Minimum</var> function.
the number of the item that has the lowest value.
<li>If the values returned by <var class="term">itemFunction</var> for two or more <var>FloatNamedArraylist</var> items are equal, minimum, values, <var>Minimum</var> returns the (numeric) name of that item which is closest to the beginning of the <var>FloatNamedArraylist</var>.
Therefore, lowercase letters are ranked alphabetically and
the minimum lowercase letter is &ldquo;a&rdquo;;
<li>The <var>[[Maximum (FloatNamedArraylist function)|Maximum]]</var> function is the opposite of the <var>Minimum</var> function.
the uppercase letters are ranked alphabetically and
the minimum uppercase letter is &ldquo;A&rdquo;;
<li><var class="term">itemFunction</var> is a method value, not a <var class="product">User Language</var> expression.
&ldquo;z&rdquo; ranks lower than all the uppercase letters;
That is, you cannot provide a function that itself has an argument (say, <code>ToIntegerPower(2)</code>) as the <var>Minimum</var> parameter.
and all letters rank lower than any number.
Example [[Maximum (Arraylist function)|"Maximum/Minimum with local method"]] shows a way to apply <var>ToIntegerPower</var>
<li>If one or more FloatNamedArraylist items have equal, minimum, values,
with <var>Maximum</var> or <var>Minimum</var> for an <var>Arraylist</var>.
Minimum returns the subscript of the item that appears closest to the beginning
of the FloatNamedArraylist.
<li>The [[Maximum (FloatNamedArraylist 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.
Example "[[Maximum (Arraylist function)|Maximum/Minimum with local method]]" shows a way to apply ToIntegerPower
with Maximum or Minimum for an Arraylist.
</ul>
</ul>
==Examples==
==Examples==
 
<ol>
The following request finds the minimum and maximum
<li>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]].
<p class="code">b
<pre style="xmp">
class annual
    b
public
    class annual
variable ybegin is float
    public
variable yend is float
      variable ybegin is float
constructor newa (%beg is float, %end is float)
      variable yend is float
function myprint is string len 24
      constructor newa (%beg is float, %end is float)
function chg is float
      function myprint is string len 24
end public
      function chg is float
    end public
constructor newa (%beg is float, %end is float)
 
  %ybegin = %beg
    constructor newa (%beg is float, %end is float)
  %yend = %end
      %ybegin = %beg
end constructor
      %yend = %end
    end constructor
function myprint is string len 24
 
  return 'ybegin=' with %ybegin with ', ' -
    function myprint is string len 24
      with 'yend=' with %yend
      return 'ybegin=' with %ybegin with ', ' -
end function
        with 'yend=' with %yend
    end function
function chg is float
 
  %chg is float
    function chg is float
  %chg = %yend - %ybegin
      %chg is float
  return %chg
      %chg = %yend - %ybegin
end function
      return %chg
    end function
End class
 
    End class
%fann is floatnamedArraylist of object annual
 
%fann = new
    %fann is floatnamedArraylist of object annual
%fann(12) = newa(621, 650)
    %fann = new
%fann(14) = newa(334, 343)
    %fann(12) = newa(621, 650)
%fann(15) = newa(288, 276)
    %fann(14) = newa(334, 343)
%fann(13) = newa(141, 182)
    %fann(15) = newa(288, 276)
%fann(11) = newa(131, 115)
    %fann(13) = newa(141, 182)
    %fann(11) = newa(131, 115)
%i is float
 
for %i from 1 to %fann:count
    %i is float
  print %fann:namebynumber(%i) With ': ' -
    for %i from 1 to %fann:count
      print %fann:namebynumber(%i) With ': ' -
       With %fann:itembynumber(%i):myprint
       With %fann:itembynumber(%i):myprint
    end for
end for
 
    print 'item ' %fann:minimum(chg) ' has the minimum increase'
print 'item ' %fann:minimum(chg) ' has the minimum increase'
    print 'item ' %fann:maximum(chg) ' has the maximum increase'
print 'item ' %fann:maximum(chg) ' has the maximum increase'
 
    end
end
</pre>
</p>
 
The result is.
The result is.
<pre style="xmp">
<p class="output">11: ybegin=131, yend=115
    11: ybegin=131, yend=115
12: ybegin=621, yend=650
    12: ybegin=621, yend=650
13: ybegin=141, yend=182
    13: ybegin=141, yend=182
14: ybegin=334, yend=343
    14: ybegin=334, yend=343
15: ybegin=288, yend=276
    15: ybegin=288, yend=276
item 11 has the minimum increase
    item 11 has the minimum increase
item 13 has the maximum increase
    item 13 has the maximum increase
</p>
</pre>
<li>For more examples, see the <var>NamedArraylist</var> <var>Minimum</var> [[Minimum (NamedArraylist function)#Examples|"Examples"]] and
[[Collections#Finding collection maxima and minima, and sorting|"Finding collection maxima and minima, and sorting"]].
</ol>
==See also==
{{Template:FloatNamedArraylist:Minimum footer}}

Latest revision as of 23:11, 10 August 2012

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


Minimum returns the (numeric) name of the FloatNamedArraylist item that has the minimum value as returned by a specified function. The function applied to each FloatNamedArraylist item, which you specify with the required itemFunction argument, must be a method that operates on the item type and returns a User Language intrinsic datatype (Float, String, or Unicode) value.

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 name of the item in fltNal, the method FloatNamedArraylist object, that has the minimum value as returned by the argument function.
fltNal A FloatNamedArraylist object.
itemFunction A method value (a method name literal, a method variable, or even a method that returns a method value) that operates on objects of the type specified on the fltNal declaration and that returns an intrinsic value. As of Sirius Mods version 7.6, the special identity function, This, is the default itemFunction value for the Maximum and Minimum methods. See "Using the This function as the Maximum parameter".

Usage notes

  • If itemFunction returns String or Unicode values, Minimum uses the collating sequence of EBCDIC or Unicode, respectively, to determine which item that has the lowest value. If itemFunction returns a numeric type, numeric comparisons are used. See the "example" for the NamedArraylist Minimum function.
  • If the values returned by itemFunction for two or more FloatNamedArraylist items are equal, minimum, values, Minimum returns the (numeric) name of that item which is 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

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

    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

  2. For more examples, see the NamedArraylist Minimum "Examples" and "Finding collection maxima and minima, and sorting".

See also