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

12
LINES

< > BotCompany Repo | #1030348 // indentedStringsToForest

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2934L/18K).

static L<Tree<S>> indentedStringsToForest(LS l) {
  if (empty(l)) ret emptyList();
  int baseIndent = indentWidth(first(l));
  new L<Tree<S>> forest;
  for ping (int i = 0; i < l(l); ) {
    int j = i+1;
    while (j < l(l) && indentWidth(l.get(j)) > baseIndent) ++j;
    forest.add(new Tree<S>(ltrim(l.get(i)), indentedStringsToForest(subList(l, i+1, j))));
    i = j;
  }
  ret forest;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030348
Snippet name: indentedStringsToForest
Eternal ID of this version: #1030348/5
Text MD5: d32caa18489b0f2fd68ba540cf60c4f0
Transpilation MD5: e8ffdfe95ae795e2031d9adde775ccca
Author: stefan
Category: javax / parsing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-12-05 21:04:35
Source code size: 400 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 110 / 165
Version history: 4 change(s)
Referenced in: [show references]