Bin given limits: Difference between revisions
Content deleted Content added
→{{header|Raku}}: Added Raku solution |
m →{{header|REXX}}: added code to adjust for the true width of the counts. |
||
Line 240: | Line 240: | ||
end /*j*/; return |
end /*j*/; return |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
bins: parse arg nums; !.=0 |
bins: parse arg nums; !.=0; datum= words(nums); wc= length(datum) /*max width count. */ |
||
⚫ | |||
wd= 0 /*max width data #s*/ |
|||
⚫ | |||
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 the bin counter. */ |
if x< @.k then do; !.k= !.k + 1; iterate j; end /*bump the bin counter. */ |
||
Line 252: | Line 251: | ||
say center('' , 50, "═") /*show title separator. */ |
say center('' , 50, "═") /*show title separator. */ |
||
ge= '≥'; eq= ' count=' |
ge= '≥'; eq= ' count=' |
||
do j=0 for #; jm= j - 1; idx= right(@.j, wb); cnt= right(!.j, |
do j=0 for #; jm= j - 1; idx= right(@.j, wb); cnt= right(!.j, wc) |
||
if j==0 then say pad left('', length(ge) +1+wb+2+length(..) )"<" idx eq |
if j==0 then say pad left('', length(ge) +1+wb+2+length(..) )"<" idx eq cnt |
||
else say pad ge right(@.jm, wb) .. "<" idx eq |
else say pad ge right(@.jm, wb) .. "<" idx eq cnt |
||
end /*j*/ |
end /*j*/ |
||
jm= j - 1; cnt= right(!.j, |
jm= j - 1; cnt= right(!.j, wc) |
||
say pad ge right(@.jm, wb) left('', 3 + length(..) + wb) eq |
say pad ge right(@.jm, wb) left('', 3 + length(..) + wb) eq cnt |
||
return</lang> |
return</lang> |
||
{{out|output|text= when using the internal default input:}} |
{{out|output|text= when using the internal default input:}} |