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

16
LINES

< > BotCompany Repo | #1020232 // f0_randomLL_differentEveryTime

JavaX fragment (include)

1  
static <A> F0<A> f0_randomLL_differentEveryTime(final A... l) {
2  
  ret new F0<A>() {
3  
    int last = -1;
4  
    
5  
    public A get() {
6  
      int idx;
7  
      if (last == -1) idx = random(l(l));
8  
      else {
9  
        idx = random(l(l)-1);
10  
        if (idx >= last) ++idx;
11  
      }
12  
      last = idx;
13  
      ret _get(l, idx);
14  
    }
15  
  };
16  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1020232
Snippet name: f0_randomLL_differentEveryTime
Eternal ID of this version: #1020232/3
Text MD5: 0cf727557c83de08ffb77f5612673300
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-12-11 02:18:26
Source code size: 338 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 314 / 338
Version history: 2 change(s)
Referenced in: [show references]