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

16
LINES

< > BotCompany Repo | #1003343 // unrollTree

JavaX fragment (include)

static <A> L<L<A>> unrollTree(OccTree<A> tree) {
  new L<L<A>> l;
  unrollTree_collect(tree, new ArrayList, l);
  ret l;
}

static <A> void unrollTree_collect(OccTree<A> tree, L<A> l, L<L<A>> out) {
  for (A a : keys(tree.followUp)) {
    l.add(a);
    unrollTree_collect(tree.followUp(a), l, out);
    removeLast(l);
  }
  
  if (empty(tree.followUp))
    out.add(cloneList(l));
}

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: #1003343
Snippet name: unrollTree
Eternal ID of this version: #1003343/1
Text MD5: 1313d93a25bf8a14a31791299307ff50
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-06-19 23:02:38
Source code size: 396 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 581 / 573
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)