Bin given limits: Difference between revisions
Content added Content deleted
m (Correction to task description.) |
m (→{{header|REXX}}: simplified some code.) |
||
Line 553: | Line 553: | ||
exit 0 /*stick a fork in it, we're all done. */ |
exit 0 /*stick a fork in it, we're all done. */ |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
bins: parse arg nums; !.= 0; datum= words(nums); wc= length(datum) /*max width count.*/ |
|||
⚫ | |||
⚫ | |||
⚫ | |||
bins: parse arg nums; !.=0; datum= words(nums); wc= length(datum) /*max width count. */ |
|||
do j=1 for datum; x= word(nums, j) |
do j=1 for datum; x= word(nums, j) |
||
do k=0 for # /*find the bin that this number is in. */ |
do k=0 for # /*find the bin that this number is in. */ |
||
if x < @.k then do; !.k= !.k + 1; iterate j; end /*bump |
if x < @.k then do; !.k= !.k + 1; iterate j; end /*bump a bin count*/ |
||
end /*k*/ |
end /*k*/ |
||
!.k= !.k + 1 /* |
!.k= !.k + 1 /*number is > the highest bin specified*/ |
||
end /*j*/; return |
end /*j*/; return |
||
⚫ | |||
lims: parse arg limList; #= words(limList); wb= 0 /*max width binLim*/ |
|||
⚫ | |||
⚫ | |||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
show: say center( |
show: parse arg t; say center(t, 51 ); $= left('', 9) /*$: for indentation*/ |
||
say center('', 51, "═") /*show title separator.*/ |
|||
jp= #-1; |
jp= # - 1; ge= '≥'; le='<'; eq= ' count=' |
||
do j=0 for #; jm= j - 1; |
do j=0 for #; jm= j - 1; bin= right(@.j, wb) |
||
if j==0 then say $ left('', length(ge)+ |
if j==0 then say $ left('', length(ge) +3+wb+length(..) )le bin eq right(!.j, wc) |
||
else say $ ge right(@.jm, wb) .. |
else say $ ge right(@.jm, wb) .. le bin eq right(!.j, wc) |
||
if j==jp then say $ ge right(@.jp, |
if j==jp then say $ ge right(@.jp,wb) left('', 3+length(..)+wb) eq right(!.#, wc) |
||
end /*j*/; return</lang> |
end /*j*/; return</lang> |
||
{{out|output|text= when using the internal default input:}} |
{{out|output|text= when using the internal default input:}} |
||
<pre> |
<pre> |