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

19
LINES

< > BotCompany Repo | #1018056 // replaceVars_withDollarQ

JavaX fragment (include)

1  
static S replaceVars_withDollarQ(S s, SS map) {
2  
  ret empty(map) ? s : join(replaceVars_withDollarQ(javaTok(s), map));
3  
}
4  
  
5  
static LS replaceVars_withDollarQ(LS tok, SS map) {
6  
  if (empty(map)) ret tok;
7  
  tok = cloneList(tok);
8  
  for (int i = 1; i < l(tok); i +=2) {
9  
    S t = tok.get(i);
10  
    S value = map.get(t);
11  
    if (value != null)
12  
      tok.set(i, value);
13  
    else if (t.startsWith("$_q_")) {
14  
      value = map.get("$" + substring(t, 4));
15  
      if (value != null) tok.set(i, quote(value));
16  
    }
17  
  }
18  
  ret tok;
19  
}

Author comment

Began life as a copy of #1004293

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1018056
Snippet name: replaceVars_withDollarQ
Eternal ID of this version: #1018056/3
Text MD5: 2eb6a330296d107808bc8b36b18a2e65
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-08-29 00:26:11
Source code size: 536 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 277 / 320
Version history: 2 change(s)
Referenced in: [show references]