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)

static <A> F0<A> f0_randomLL_differentEveryTime(final A... l) {
  ret new F0<A>() {
    int last = -1;
    
    public A get() {
      int idx;
      if (last == -1) idx = random(l(l));
      else {
        idx = random(l(l)-1);
        if (idx >= last) ++idx;
      }
      last = idx;
      ret _get(l, idx);
    }
  };
}

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: 313 / 337
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)