Libraryless. Click here for Pure Java version (11438L/64K).
1 | // jreplace_multi goes over ins/outs once (doesn't loop) |
2 | |
3 | sbool jreplace_multi(LS tok, LS ins, S out) { |
4 | bool change = false; |
5 | for (S in : ins) |
6 | if (jreplace(tok, in, out)) |
7 | change = true; |
8 | ret change; |
9 | } |
10 | |
11 | sS jreplace_multi(S s, S... replacements) { |
12 | if (empty(replacements)) ret s; |
13 | LS tok = javaTok(s); |
14 | bool change; |
15 | for (int i = 0; i < l(replacements); i += 2) |
16 | if (jreplace(tok, replacements[i], replacements[i+1])) |
17 | set change; |
18 | ret change ? join(tok) : s; |
19 | } |
20 | |
21 | static LS jreplace_multi(LS tok, S... replacements) { |
22 | for (int i = 0; i < l(replacements); i += 2) |
23 | jreplace(tok, replacements[i], replacements[i+1]); |
24 | ret tok; |
25 | } |
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1020948 |
Snippet name: | jreplace_multi |
Eternal ID of this version: | #1020948/7 |
Text MD5: | fd4258552d24ad9fcc1907f3f77f277f |
Transpilation MD5: | 8da3bc7e683dc85440ec7d6a24ae9bf1 |
Author: | stefan |
Category: | javax / transpiling |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2023-09-17 20:39:41 |
Source code size: | 681 bytes / 25 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 422 / 564 |
Version history: | 6 change(s) |
Referenced in: | [show references] |