1 | // map: index of opening bracket -> index of closing bracket |
2 | static Map<Int> curlyBracketMapC(L<S> tok) {
|
3 | new TreeMap<Int, Int> map; |
4 | new L<int> stack; |
5 | int n = l(tok); |
6 | for i to n: {
|
7 | S t = tok.get(i); |
8 | if (eq(t, "{"))
|
9 | stack.add(i); |
10 | else if (eq(t, "}") && nempty(stack)) |
11 | map.put(liftLast(stack), i); |
12 | } |
13 | ret map; |
14 | } |
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: | 699 / 712 |
| Referenced in: | [show references] |