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

14
LINES

< > BotCompany Repo | #1027123 // format3_round - format star pattern, group arguments in round brackets if longer than one token

JavaX fragment (include)

sS format3_round(S pat, S... args) {
  if (empty(args)) ret pat;
  
  L<S> tok = javaTok(pat);
  int argidx = 0;
  for (int i = 1; i < tok.size(); i += 2)
    if (tok.get(i).equals("*"))
      tok.set(i, roundOpt(argidx < args.length ? args[argidx++] : "null"));
  ret join(tok);
}

sS format3_round(S pat, LS args) {
  ret format3_round(pat, asStringArray(args));
}

Author comment

Began life as a copy of #1021066

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: #1027123
Snippet name: format3_round - format star pattern, group arguments in round brackets if longer than one token
Eternal ID of this version: #1027123/3
Text MD5: 4c81a0d07f7f4d7625ecab3f0000a9c6
Author: stefan
Category: javax / parsing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-21 13:10:34
Source code size: 379 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 253 / 280
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)