static S rules_unfoldIndented(S s, S prefix) { if (containsTabs(s)) warn("Tabs in input"); s = s.replace("\t", " "); L<S> lines = toLines(s); for i over lines: { S line = lines.get(i); S trimmed = trim(line); if (empty(trimmed)) continue; int n = getIndent(line); int j = i+1; bool any = false; while (j < l(lines)) { if (emptyAfterTrim(lines.get(j))) ++j; else if (getIndent(lines.get(j)) > n) { ++j; any = true; } else break; } if (!any) continue; lines.set(i, ""); while (i+1 < j) { ++i; S l = lines.get(i); if (!emptyAfterTrim(l)) lines.set(i, rep(' ', getIndent(l)) + prefix + "(" + trimmed + ") & " + trim(l)); } } ret fromLines(lines); }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1008322 |
Snippet name: | rules_unfoldIndented |
Eternal ID of this version: | #1008322/10 |
Text MD5: | 3ae1f1bcec807e6d2448ed2cb1403b48 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-05-07 21:38:16 |
Source code size: | 786 bytes / 28 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 472 / 511 |
Version history: | 9 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |