Libraryless. Click here for Pure Java version (54L/1K).
// i must point at the (possibly imaginary) closing bracket // index returned is index of opening bracket static int findBeginningOfBlock(LS cnc, int i) { int j = i-2, level = 1; while (j > 0) { if (eq(cnc.get(j), "}")) ++level; else if (eq(cnc.get(j), "{")) --level; if (level == 0) ret j; j -= 2; } ret -1; }
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: | 699 / 699 |
Version history: | 3 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #3000382 - Answer for ferdie (>> t = 1, f = 0) #3000383 - Answer for funkoverflow (>> t=1, f=0 okay) |