// map: index of opening bracket -> index of closing bracket static Map<Int> curlyBracketMapC(L<S> tok) { new TreeMap<Int, Int> map; new L<int> stack; int n = l(tok); for i to n: { S t = tok.get(i); if (eq(t, "{")) stack.add(i); else if (eq(t, "}") && nempty(stack)) map.put(liftLast(stack), i); } ret map; }
Began life as a copy of #1010376
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: | #1011742 |
Snippet name: | curlyBracketMapC (takes code tokens) |
Eternal ID of this version: | #1011742/1 |
Text MD5: | b6a8e0ca6c29b7690da1e4fe29b4690a |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-11-04 23:34:09 |
Source code size: | 357 bytes / 14 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 478 / 486 |
Referenced in: | [show references] |