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

20
LINES

< > BotCompany Repo | #1001250 - format3

JavaX fragment (include)

  static S format3(S pat, O... args) {
    if (args.length == 0) return pat;
    
    L<S> tok = javaTokPlusPeriod(pat);
    int argidx = 0;
    for (int i = 1; i < tok.size(); i += 2)
      if (tok.get(i).equals("*"))
        tok.set(i, format3_formatArg(argidx < args.length ? args[argidx++] : "null"));
    return join(tok);
  }
  
  static S format3_formatArg(O arg) {
    if (arg == null) return "null";
    if (arg instanceof String) {
      S s = (S) arg;
      ret isIdentifier(s) || isNonNegativeInteger(s) ? s : quote(s);
    }
    if (arg instanceof Integer || arg instanceof Long) ret String.valueOf(arg);
    return quote(structure(arg));
  }
  

download  show line numbers  debug dex   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, jozkyjcghlvl, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, whxojlpjdney

No comments. add comment

Snippet ID: #1001250
Snippet name: format3
Eternal ID of this version: #1001250/1
Text MD5: 81654dcbdaa209319012fa6a37dc1a4e
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-12-18 18:06:02
Source code size: 680 bytes / 20 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 503 / 8252
Referenced in: [show references]

Formerly at http://tinybrain.de/1001250 & http://1001250.tinybrain.de