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

12
LINES

< > BotCompany Repo | #1028373 // replaceStarsWithCountingDollarVars - * to $1, $2, ...

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2829L/18K).

1  
sS replaceStarsWithCountingDollarVars(S s) {
2  
  ret join(replaceStarsWithCountingDollarVars(javaTokWithAllBrackets_cached(s)));
3  
}
4  
5  
static LS replaceStarsWithCountingDollarVars(LS tok) {
6  
  int varCounter = 0;
7  
  tok = cloneList(tok);
8  
  for (int i = 1; i < l(tok); i += 2)
9  
    if (eq(tok.get(i), "*"))
10  
      tok.set(i, "$" + (++varCounter));
11  
  ret tok;
12  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028373
Snippet name: replaceStarsWithCountingDollarVars - * to $1, $2, ...
Eternal ID of this version: #1028373/6
Text MD5: 45f19401b627428a0f26856f9b43e6a5
Transpilation MD5: fab2e17b0b55d2f8a27cb0e0f1296b0e
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-06-14 17:04:41
Source code size: 361 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 176 / 291
Version history: 5 change(s)
Referenced in: [show references]