Libraryless. Click here for Pure Java version (2689L/17K).
sS gazelle_deepReplaceVars(SS map, S s, O... _) { SS map2 = mapValues roundIfMultipleTokensUnlessCurlyBracketed(map); ret gazelle_deepReplaceVars_impl(map2, s, _); } sS gazelle_deepReplaceVars_impl(SS map, S s, O... _) { LS tok = javaTokWithBrackets(s); ret join(mapCodeTokens(tok, t -> { //bool round = tok_isRoundBracketed(t); //bool curly = tok_isCurlyBracketed(t); S t2 = tok_deRoundOrCurlyBracket(t); S t3 = map.get(t2); ifdef gazelle_deepReplaceVars_debug print("sub lookup: " + quote(t2) + " => " + quote(t3)); endifdef if (t3 != null) ret t3; if (l(tok) == 3) ret t; S t4 = gazelle_deepReplaceVars_impl(map, t2, _); if (eq(t4, t2)) ret t; //ret round ? roundBracket(t4) : curlyBracket(t4); ret roundBracketOptIfMoreThanOneToken(t4); })); }
Began life as a copy of #1025738
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: | #1025840 |
Snippet name: | gazelle_deepReplaceVars - doesn't auto-bracket map values |
Eternal ID of this version: | #1025840/13 |
Text MD5: | 93c355a9e362a0c0adfff4acb50836ee |
Transpilation MD5: | 8e57d93b36d678f98d6135921f286cbb |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-10-26 05:39:13 |
Source code size: | 832 bytes / 23 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 267 / 436 |
Version history: | 12 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |