Libraryless. Click here for Pure Java version (2396L/15K).
1 | sS arbitraryVarsToStars(S s, Set<S> vars, LS varNames_out) { |
2 | if (empty(vars)) ret s; |
3 | LS tok = javaTok(s); |
4 | LS tok2 = arbitraryVarsToStars(tok, vars, varNames_out); |
5 | ret tok == tok2 ? s : join(tok2); |
6 | } |
7 | |
8 | static LS arbitraryVarsToStars(LS tok, Set<S> vars, LS varNames_out) { |
9 | if (empty(vars)) ret tok; |
10 | LS tok2 = null; |
11 | int n = l(tok); |
12 | for i to n: { |
13 | S t = tok.get(i); |
14 | if (odd(i) && vars.contains(t)) { |
15 | listAdd(varNames_out, t); |
16 | if (tok2 == null) tok2 = cloneSubList(tok, 0, i); |
17 | tok2.add("*"); |
18 | } else |
19 | if (tok2 != null) tok2.add(t); |
20 | } |
21 | ret tok2 != null ? tok2 : tok; |
22 | } |
Began life as a copy of #1010854
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1026162 |
Snippet name: | arbitraryVarsToStars |
Eternal ID of this version: | #1026162/6 |
Text MD5: | ab7fa29a7c86f710ae4ae9f664c5d20b |
Transpilation MD5: | 04fe41f109a72c01007662fe52bb51fb |
Author: | stefan |
Category: | javax / parsing |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-11-28 13:53:02 |
Source code size: | 635 bytes / 22 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 222 / 333 |
Version history: | 5 change(s) |
Referenced in: | [show references] |