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

12
LINES

< > BotCompany Repo | #1014026 // selectRandomWithMultiples - select n random elements from list (in random order, with duplicates)

JavaX fragment (include)

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

static <A> L<A> selectRandomWithMultiples(L<A> list, int n) {
  if (empty(list)) null;
  new L<A> l;
  repeat n {
    l.add(random(list));
  }
  ret l;
}

Author comment

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: 428 / 448
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)