Anonymous user
Knuth's algorithm S: Difference between revisions
m
→{{header|REXX}}: changed (back again) the subroutine/function names to conform to the Rosetta Code task requirements.
m (→{{header|REXX}}: added/changed whitespace and comments, ordered the subroutines/functions, broke a long statement into smaller ones.) |
m (→{{header|REXX}}: changed (back again) the subroutine/function names to conform to the Rosetta Code task requirements.) |
||
Line 1,245:
#.=0 /*initialize frequency counter array. */
do trials /*OK, now let's light this candle. */
call
do gener=0 for 10
call
end /*gener*/
Line 1,269:
do j=e to b by -3; _=insert(',',_,j); end /*j*/; return _
/*────────────────────────────────────────────────────────────────────────────*/
c=random(1, items) /* [↓] should replace a previous item?*/
if c>size then return /*probability isn't good, so skip it. */
Line 1,275:
return /* ··· item to replace with ITEM.*/
/*────────────────────────────────────────────────────────────────────────────*/
do k=1 for item /*traipse through the first N items. */
!.k=random(0, 9) /*set the Kth item with random digit.*/
|