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

22
LINES

< > BotCompany Repo | #1007817 // xyzToNewIDs - replace X, Y, Z etc. with new ids

JavaX fragment (include)

1  
static S xyzToNewIDs(S s) {
2  
  ret xyzToNewIDs(s, (L<S>) null);
3  
}
4  
5  
static S xyzToNewIDs(S s, L<S> varCollector) {
6  
  L<S> tok = javaTok(s);
7  
  int n = numberOfXYZVars(tok);
8  
  for (int i = 1; i <= n; i++) {
9  
    S var = xyzIndexToVar(i);
10  
    if (tok.contains(var))
11  
      replace(tok, var, addAndReturn(varCollector, aGlobalID()));
12  
  }
13  
  ret join(tok);
14  
}
15  
16  
static S xyzToNewIDs(S s, S... varsToReplace) {
17  
  L<S> tok = javaTok(s);
18  
  for (S var : varsToReplace)
19  
    if (tok.contains(var))
20  
      replace(tok, var, aGlobalID());
21  
  ret join(tok);
22  
}

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: #1007817
Snippet name: xyzToNewIDs - replace X, Y, Z etc. with new ids
Eternal ID of this version: #1007817/8
Text MD5: 14a38e5ae174d358a238e532d5f44f82
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-04-30 00:16:15
Source code size: 557 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 564 / 558
Version history: 7 change(s)
Referenced in: [show references]