1 | static <A> L<A> selectRandomWithMultiples(int n, L<A> list) { |
2 | ret selectRandomWithMultiples(list, n); |
3 | } |
4 | |
5 | static <A> L<A> selectRandomWithMultiples(L<A> list, int n) { |
6 | if (empty(list)) null; |
7 | new L<A> l; |
8 | repeat n { |
9 | l.add(random(list)); |
10 | } |
11 | ret l; |
12 | } |
Began life as a copy of #1002448
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1014026 |
Snippet name: | selectRandomWithMultiples - select n random elements from list (in random order, with duplicates) |
Eternal ID of this version: | #1014026/1 |
Text MD5: | 36404973cd9e8cb51cc967523170ac5a |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-03-23 20:24:25 |
Source code size: | 271 bytes / 12 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 427 / 448 |
Referenced in: | [show references] |