P23 - 从列表中随机抽取指定数量的元素。
作者:Ryan Connelly
示例
> say get-rand-elems(<a b c d e>, 3); c b a
源代码: P23-topo.pl
use v6;
sub get-rand-elems(@list, $amount) {
@list.pick($amount);
}
say "{get-rand-elems(<a b c d e>, 3)}";
作者:Ryan Connelly
> say get-rand-elems(<a b c d e>, 3); c b a
源代码: P23-topo.pl
use v6;
sub get-rand-elems(@list, $amount) {
@list.pick($amount);
}
say "{get-rand-elems(<a b c d e>, 3)}";