Libraryless. Click here for Pure Java version (54L/1K).
1 | // i must point at the (possibly imaginary) closing bracket |
2 | // index returned is index of opening bracket |
3 | static int findBeginningOfBlock(LS cnc, int i) { |
4 | int j = i-2, level = 1; |
5 | while (j > 0) { |
6 | if (eq(cnc.get(j), "}")) ++level; |
7 | else if (eq(cnc.get(j), "{")) --level; |
8 | if (level == 0) |
9 | ret j; |
10 | j -= 2; |
11 | } |
12 | ret -1; |
13 | } |
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: | #1002443 |
Snippet name: | findBeginningOfBlock |
Eternal ID of this version: | #1002443/4 |
Text MD5: | 749911dbf4a809f848346152ded5367d |
Transpilation MD5: | 0ecb11806590e126709446aceedab8e1 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-11-04 12:13:57 |
Source code size: | 352 bytes / 13 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 700 / 700 |
Version history: | 3 change(s) |
Referenced in: | [show references] |