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).

sS replaceStarsWithCountingDollarVars(S s) {
  ret join(replaceStarsWithCountingDollarVars(javaTokWithAllBrackets_cached(s)));
}

static LS replaceStarsWithCountingDollarVars(LS tok) {
  int varCounter = 0;
  tok = cloneList(tok);
  for (int i = 1; i < l(tok); i += 2)
    if (eq(tok.get(i), "*"))
      tok.set(i, "$" + (++varCounter));
  ret tok;
}

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: 119 / 209
Version history: 5 change(s)
Referenced in: [show references]