Libraryless. Click here for Pure Java version (10462L/58K).
svoid tok_metaFor(LS tok) { int i; jreplace(tok, "meta-for <id> also as", "meta-for $4 in $4,"); while ((i = jfind_any(tok, "meta-for <id> in", "meta-for <id> as")) >= 0) { int iOpening = indexOf(tok, i, "{"); int iClosing = tok_findEndOfBracketPart(tok, iOpening)-1; int iVar = i+6, iFirstValue = iVar+4; S var = tok.get(iVar); LS values = identifiersOnly(subList(tok, iFirstValue, iOpening-1)); LS body = subList(tok, iOpening+1, iClosing); tokReplace_reTok(tok, i, iClosing+1, mapToLines(values, value -> join(replaceInClonedList(body, var, value)))); } }
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
Snippet ID: | #1031922 |
Snippet name: | tok_metaFor |
Eternal ID of this version: | #1031922/11 |
Text MD5: | e50333930b0a0f8169e5c348ad2a19ee |
Transpilation MD5: | 984a99db28d896738fb89123504d0734 |
Author: | stefan |
Category: | javax / transpiling |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-07-19 23:51:40 |
Source code size: | 646 bytes / 20 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 173 / 300 |
Version history: | 10 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |