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

15
LINES

< > BotCompany Repo | #1002880 // nlMakeUnusedVar

JavaX fragment (include)

static S nlMakeUnusedVar(S text) {
  L<S> tok = nlTok(text);
  new TreeSet<S> usedVars;
  for (int i = 1; i < l(tok); i += 2) {
    S t = tok.get(i);
    if (t.startsWith("$") && l(t) > 1)
      usedVars.add(t);
  }
  for (int i = 0; i < 26; i++) {
    S var = "$" + (char) (((int) 'a') + i);
    if (!usedVars.contains(var))
      ret var;
  }
  throw fail("Help help help too many variables!");
}

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: #1002880
Snippet name: nlMakeUnusedVar
Eternal ID of this version: #1002880/1
Text MD5: 0cffb87d98c4d96e5a1b7f04fc87a2c5
Author: stefan
Category: eleu / nl
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-03-13 20:17:22
Source code size: 412 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 640 / 599
Referenced in: [show references]