// map: index of opening bracket -> index of closing bracket static Map<Int> curlyBracketMap(L<S> tok) { new TreeMap<Int, Int> map; new L<int> stack; int n = l(tok); for (int i = 1; i < n; i += 2) { 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 #1011742
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: | #1011744 |
Snippet name: | curlyBracketMap |
Eternal ID of this version: | #1011744/1 |
Text MD5: | db1c13c0d12d6c5f5fcc3cac4c691bb4 |
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:40:23 |
Source code size: | 375 bytes / 14 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 473 / 521 |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |