Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

14
LINES

< > BotCompany Repo | #1018189 // ai_indentToCurlyBraces

JavaX fragment (include)

1  
sS ai_indentToCurlyBraces(S s) {
2  
  L<S> lines = lines(s);
3  
  for i over lines: {
4  
    int indent = indentCount(lines.get(i));
5  
    int j = i;
6  
    while (j+1 < l(lines) && indentCount(lines.get(j+1)) > indent) ++j;
7  
    if (j > i) {
8  
      lines.set(i, lines.get(i) + " {");
9  
      lines.set(j, lines.get(j) + " }");
10  
    }
11  
    //i = j;
12  
  }
13  
  ret lines(lines);
14  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1018189
Snippet name: ai_indentToCurlyBraces
Eternal ID of this version: #1018189/3
Text MD5: 3c63771e57cd8acb7d5457c43463b491
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-09-08 11:49:39
Source code size: 367 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 370 / 409
Version history: 2 change(s)
Referenced in: [show references]