Averages/Mode: Difference between revisions
m
→REXX Version 2: fix -- problem
m (fixed typo) |
Walterpachl (talk | contribs) m (→REXX Version 2: fix -- problem) |
||
Line 2,134:
===Version 2===
Displays all modes if there are more than one.
{{trans|NetRexx}}
Line 2,142 ⟶ 2,139:
{{works with|Regina}}
<lang REXX>/* Rexx */
/*-- ~~ main ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
call run_samples
return
exit
/*-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/*-- returns a comma separated string of mode values from a comma separated input vector string */
mode:
procedure
Line 2,189 ⟶ 2,186:
return lmodes
/*-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/*-- pretty-print */
show_mode:
procedure
Line 2,198 ⟶ 2,195:
return modes
/*-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/*-- load the "vector." stem from the comma separated input vector string */
makeStem:
procedure expose vector.
Line 2,232 ⟶ 2,229:
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
return</lang>
{{out}}
<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], 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: [30,10,20,30,40,50,-100,4.7,-11e+2], Mode(s): [30]
Line 2,252 ⟶ 2,247:
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,1,2,4,4], Mode(s): [1,4]</pre>
=={{header|Ruby}}==
|