// returns selected, rest static <A> Pair<L<A>> selectRandom2(L<A> list, int n) { if (l(list) < n) null; new L<A> l; list = cloneList(list); repeat n { int i = rand(l(list)); l.add(list.get(i)); list.remove(i); } ret pair(l, list); }
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: | #1008665 | 
| Snippet name: | selectRandom2 - select n random elements from list (in random order, no duplicates), return rest list also | 
| Eternal ID of this version: | #1008665/4 | 
| Text MD5: | 0eebaab529fa17dd815074c1b3695728 | 
| Author: | stefan | 
| Category: | javax | 
| Type: | JavaX fragment (include) | 
| Public (visible to everyone): | Yes | 
| Archived (hidden from active list): | No | 
| Created/modified: | 2017-05-27 14:03:47 | 
| Source code size: | 268 bytes / 12 lines | 
| Pitched / IR pitched: | No / No | 
| Views / Downloads: | 730 / 763 | 
| Version history: | 3 change(s) | 
| Referenced in: | [show references] |