Transpiled version (3056L) is out of date.
1 | // transformer can return null or input on no change |
2 | // will not call transformer on individual words |
3 | // returns null if no change |
4 | static WithTrail<S> lambdaMapLike gazelle_deepTransform_withTrail(IF1<S, WithTrail<S>> transformer, S input, O... _) { |
5 | if (transformer == null) null; |
6 | |
7 | // call transformer on whole input, return if change |
8 | WithTrail<S> transformed = transformer.get(input); |
9 | if (transformed != null) ret transformed; |
10 | |
11 | // transformer didn't do anything, tokenize & go through parts |
12 | O tokenizer = optPar tokenizer(_, f javaTokWithBrackets); |
13 | LS tok = callTokenizer(tokenizer, input); |
14 | |
15 | new L trails; |
16 | bool changes; |
17 | |
18 | for ping (int i = 1; i < l(tok); i += 2) { |
19 | S t = tok.get(i); |
20 | if (tok_isRoundOrCurlyBracketed(t)) { |
21 | S unBracketed = tok_deRoundOrCurlyBracket(t); |
22 | transformed = gazelle_deepTransform_withTrail(transformer, unBracketed, _); |
23 | if (transformed != null) { |
24 | if (!changes) tok = cloneList(tok); // in case a caching tokenizer was used |
25 | |
26 | // enclose in brackets & replace |
27 | tok.set(i, startsWith(t, "(") ? roundOpt(transformed!) : curlyOpt(transformed!)); |
28 | trails.add(transformed.trail); |
29 | set changes; |
30 | } |
31 | } |
32 | } |
33 | |
34 | ret changes ? WithTrail(litmap(op := "gazelle_deepTransform_withTrail", +input, +trails), join(tok)) : null; |
35 | } |
Began life as a copy of #1027141
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1027176 |
Snippet name: | gazelle_deepTransform_withTrail - call a transforming function on all inner parts of input |
Eternal ID of this version: | #1027176/4 |
Text MD5: | ecfd93d43d629a3270bf259f891457f5 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-02-24 12:14:01 |
Source code size: | 1373 bytes / 35 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 234 / 316 |
Version history: | 3 change(s) |
Referenced in: | [show references] |