Bin given limits: Difference between revisions

Content added Content deleted
m (Reordered submissions alphabetically.)
m (→‎{{header|REXX}}: simplified some code.)
Line 300: Line 300:
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 the bin counter. */
if x < @.k then do; !.k= !.k + 1; iterate j; end /*bump the bin counter.*/
end /*k*/
end /*k*/
!.k= !.k + 1 /*a number is larger than any bin lim. */
!.k= !.k + 1 /*a number is larger than any bin limit*/
end /*j*/; return
end /*j*/; return
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
show: say center(' 'arg(1)" ", 50 ); pad= left('', 9) /*PAD: for indentation.*/
show: say center(' 'arg(1)" ", 51 ); $= left('', 9) /*$: for indentation.*/
say center('' , 50, "═") /*show title separator. */
say center('' , 51, "═") /*show title separator. */
ge= '≥'; eq= ' count='
jp= #-1; ge= '≥'; eq= ' count='
do j=0 for #; jm= j - 1; idx= right(@.j, wb); cnt= right(!.j, wc)
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 cnt
if j==0 then say $ left('', length(ge)+1+wb+2+length(..))"<" idx eq right(!.j,wc)
else say pad ge right(@.jm, wb) .. "<" idx eq cnt
else say $ ge right(@.jm, wb) .. "<" idx eq right(!.j,wc)
if j==jp then say $ ge right(@.jp, wb) left('', 3+length(..)+wb) eq right(!.#,wc)
end /*j*/
jm= j - 1; cnt= right(!.j, wc)
end /*j*/; return</lang>
say pad ge right(@.jm, wb) left('', 3 + length(..) + wb) eq cnt
return</lang>
{{out|output|text=&nbsp; when using the internal default input:}}
{{out|output|text=&nbsp; when using the internal default input:}}
<pre>
<pre>
the 1st set of bin counts for the specified data:
the 1st set of bin counts for the specified data:
═══════════════════════════════════════════════════
══════════════════════════════════════════════════
< 23 count= 11
< 23 count= 11
≥ 23 .. < 37 count= 4
≥ 23 .. < 37 count= 4
≥ 37 .. < 43 count= 2
≥ 37 .. < 43 count= 2
≥ 43 .. < 53 count= 6
≥ 43 .. < 53 count= 6
≥ 53 .. < 67 count= 9
≥ 53 .. < 67 count= 9
≥ 67 .. < 83 count= 5
≥ 67 .. < 83 count= 5
≥ 83 count= 13
≥ 83 count= 13






the 2nd set of bin counts for the specified data:
the 2nd set of bin counts for the specified data:
═══════════════════════════════════════════════════
══════════════════════════════════════════════════
< 14 count= 3
< 14 count= 3
≥ 14 .. < 18 count= 0
≥ 14 .. < 18 count= 0
≥ 18 .. < 249 count= 44
≥ 18 .. < 249 count= 44
≥ 249 .. < 312 count= 10
≥ 249 .. < 312 count= 10
≥ 312 .. < 389 count= 16
≥ 312 .. < 389 count= 16
≥ 389 .. < 392 count= 2
≥ 389 .. < 392 count= 2
≥ 392 .. < 513 count= 28
≥ 392 .. < 513 count= 28
≥ 513 .. < 591 count= 16
≥ 513 .. < 591 count= 16
≥ 591 .. < 634 count= 6
≥ 591 .. < 634 count= 6
≥ 634 .. < 720 count= 16
≥ 634 .. < 720 count= 16
≥ 720 count= 59
≥ 720 count= 59
</pre>
</pre>