Libraryless. Click here for Pure Java version (2234L/14K).
// f : A -> Collection<A> // trace_out collects what the function returns static <A> Set<A> mapLike transitiveHullOfFunction_multipleInputs(O f, Cl<A> inputs, O... _) { final HashSet<A> seen = asHashSet(inputs); final Int max = cast optPar max(_); Map trace_out = cast optPar trace_out(_); // Make pool of iterators final new LinkedList<Iterator<A>> pool; fOr (A input : inputs) pool.add(iterator((Iterable<A>) callF(f, input))); int n = 0; while ping (!empty(pool) && (max == null || n < max)) { Iterator<A> it = first(pool); if (!it.hasNext()) continue with removeFirst(pool); // Get entry and check if seen already A entry = it.next(); if (!seen.add(entry)) continue; // found new entry - return and schedule for further analysis Collection<A> newStuff = cast callF(f, entry); mapPut(trace_out, entry, newStuff); if (nempty(newStuff)) pool.add(iterator(newStuff)); ++n; } ret seen; }
Began life as a copy of #1022458
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1025019 |
Snippet name: | transitiveHullOfFunction_multipleInputs |
Eternal ID of this version: | #1025019/3 |
Text MD5: | 7af36670d4aa483864259eecf39a4419 |
Transpilation MD5: | ce8e34251e0779fc46a2ee6ca49518cc |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-09-01 13:16:43 |
Source code size: | 999 bytes / 30 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 242 / 340 |
Version history: | 2 change(s) |
Referenced in: | [show references] |