Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

7
LINES

< > BotCompany Repo | #1002448 // selectRandom - select n random elements from list (in random order, no duplicates), synonym of selectRandom_fast

JavaX fragment (include)

static <A> L<A> selectRandom(int n, L<A> list) {
  ret selectRandom(list, n);
}

static <A> L<A> selectRandom(L<A> list, int n) {
  ret selectRandom_fast(list, n);
}

Author comment

returns less than n elements if list too small

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: #1002448
Snippet name: selectRandom - select n random elements from list (in random order, no duplicates), synonym of selectRandom_fast
Eternal ID of this version: #1002448/6
Text MD5: 25369e10ec6200be67c86b6790a46af2
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-22 17:19:00
Source code size: 171 bytes / 7 lines
Pitched / IR pitched: No / No
Views / Downloads: 659 / 611
Version history: 5 change(s)
Referenced in: [show references]