Knuth's algorithm S: Difference between revisions
m
→{{header|Raku}}: dispense with intermediate vars, compact code layout
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
SqrtNegInf (talk | contribs) m (→{{header|Raku}}: dispense with intermediate vars, compact code layout) |
||
Line 1,647:
(formerly Perl 6)
<syntaxhighlight lang="raku" line>sub s_of_n_creator($n) {
my (@sample, $i);
-> $item {
if ++$i <= $n { @sample.push: $item }
elsif $i.rand <
}
}
my @bin;
for ^100000 {
my &s_of_n = s_of_n_creator
}
say @bin;</syntaxhighlight>
Output:
|