P24 - 从集合 1..M 中抽取 N 个不同的随机数。
作者:Ryan Connelly
示例
> say lotto-select(6, 49); 37 8 32 15 21 46
源代码: P24-topo.pl
use v6; sub lotto-select($n, $m) { gather for ^$n { take (1 ... $m).pick(1).first; } } say "{lotto-select(6, 49)}";
作者:Ryan Connelly
> say lotto-select(6, 49); 37 8 32 15 21 46
源代码: P24-topo.pl
use v6; sub lotto-select($n, $m) { gather for ^$n { take (1 ... $m).pick(1).first; } } say "{lotto-select(6, 49)}";