Averages/Mode: Difference between revisions

Content deleted Content added
m fixed typo
Walterpachl (talk | contribs)
m →‎REXX Version 2: fix -- problem
Line 2,134: Line 2,134:


===Version 2===
===Version 2===

{{improve|rexx| use of ''single-line comments'' are not supported for all-but-one Classic REXX interpreters and are not part of the ANSI REXX standard. <br> }}

Displays all modes if there are more than one.
Displays all modes if there are more than one.
{{trans|NetRexx}}
{{trans|NetRexx}}
Line 2,142: Line 2,139:
{{works with|Regina}}
{{works with|Regina}}
<lang REXX>/* Rexx */
<lang REXX>/* Rexx */
-- ~~ main ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/*-- ~~ main ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
call run_samples
call run_samples
return
return
exit
exit


-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/*-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-- returns a comma separated string of mode values from a comma separated input vector string
/*-- returns a comma separated string of mode values from a comma separated input vector string */
mode:
mode:
procedure
procedure
Line 2,189: Line 2,186:
return lmodes
return lmodes


-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/*-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-- pretty-print
/*-- pretty-print */
show_mode:
show_mode:
procedure
procedure
Line 2,198: Line 2,195:
return modes
return modes


-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/*-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-- load the "vector." stem from the comma separated input vector string
/*-- load the "vector." stem from the comma separated input vector string */
makeStem:
makeStem:
procedure expose vector.
procedure expose vector.
Line 2,232: Line 2,229:
call show_mode '1, 3, 6, 6, 6, 6, 7, 7, 12, 12, 17' -- 6
call show_mode '1, 3, 6, 6, 6, 6, 7, 7, 12, 12, 17' -- 6
call show_mode '1, 1, 2, 4, 4' -- 4 1
call show_mode '1, 1, 2, 4, 4' -- 4 1
return
return</lang>
{{out}}
</lang>
<pre>Vector: [10,9,8,7,6,5,4,3,2,1], Mode(s): [10,9,8,7,6,5,4,3,2,1]
'''Output:'''
<pre>
Vector: [10,9,8,7,6,5,4,3,2,1], Mode(s): [10,9,8,7,6,5,4,3,2,1]
Vector: [10,9,8,7,6,5,4,3,2,1,0,0,0,0,0.11], Mode(s): [0]
Vector: [10,9,8,7,6,5,4,3,2,1,0,0,0,0,0.11], Mode(s): [0]
Vector: [30,10,20,30,40,50,-100,4.7,-11e+2], Mode(s): [30]
Vector: [30,10,20,30,40,50,-100,4.7,-11e+2], Mode(s): [30]
Line 2,252: Line 2,247:
Vector: [3,1,4,1,5,9,7,6,3], Mode(s): [1,3]
Vector: [3,1,4,1,5,9,7,6,3], Mode(s): [1,3]
Vector: [1,3,6,6,6,6,7,7,12,12,17], Mode(s): [6]
Vector: [1,3,6,6,6,6,7,7,12,12,17], Mode(s): [6]
Vector: [1,1,2,4,4], Mode(s): [1,4]
Vector: [1,1,2,4,4], Mode(s): [1,4]</pre>
</pre>


=={{header|Ruby}}==
=={{header|Ruby}}==