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

14
LINES

< > BotCompany Repo | #1018189 // ai_indentToCurlyBraces

JavaX fragment (include)

sS ai_indentToCurlyBraces(S s) {
  L<S> lines = lines(s);
  for i over lines: {
    int indent = indentCount(lines.get(i));
    int j = i;
    while (j+1 < l(lines) && indentCount(lines.get(j+1)) > indent) ++j;
    if (j > i) {
      lines.set(i, lines.get(i) + " {");
      lines.set(j, lines.get(j) + " }");
    }
    //i = j;
  }
  ret lines(lines);
}

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: 364 / 402
Version history: 2 change(s)
Referenced in: [show references]