Libraryless. Click here for Pure Java version (2682L/17K).
// order of returned elements is undefined, but root is returned first // doesn't uniquify output, so make sure you don't produce a loop static <A> ItIt<A> recursiveIterator(A root, IF1<A, Iterable<A>> getChildren) { LinkedList<A> list = llLinkedList(root); ret iff(func { if (empty(list)) ret endMarker(); A a = popFirst(list); addAll(list, getChildren.get(a)); ret a; }); }
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1029281 |
Snippet name: | recursiveIterator |
Eternal ID of this version: | #1029281/2 |
Text MD5: | 3edc9ec1a8ae59790133b3a5b74ad5ec |
Transpilation MD5: | 69c241520639054949c619a8fc382486 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-07-29 20:43:27 |
Source code size: | 415 bytes / 12 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 189 / 267 |
Version history: | 1 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1029309 - uniqueRecursiveIterator - only returns each element once |