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

7
LINES

< > TinyBrain | #1007376 - selectRandomPair - select a random pair from a list

JavaX fragment (include)

static <A> Pair<A, A> selectRandomPair(L<A> l) {
  if (l(l) < 2) null;
  int i = rand(l(l));
  int j = rand(l(l)-1);
  if (j >= i) ++j;
  ret pair(l.get(i), l.get(j));
}

Author comment

Began life as a copy of #1002448

download  show line numbers  debug dex   

Travelled to 1 computer(s): tvejysmllsmz

No comments. add comment

Snippet ID: #1007376
Snippet name: selectRandomPair - select a random pair from a list
Eternal ID of this version: #1007376/3
Text MD5: 7f10dc3dd1d83819af9c8a20c660a939
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-03-18 16:23:07
Source code size: 175 bytes / 7 lines
Pitched / IR pitched: No / No
Views / Downloads: 14 / 2
Version history: 2 change(s)
Referenced in: [show]