static L<Concept> unrollOptions(Concept c) { if (c << Options) ret concatMap("unrollOptions", c/Options); if (!conceptHasOptions(c)) ret ll(c); else { // c has Options hidden somewhere within - recurse & "multiply" new Map<S, O> simples; Map<S, L<Concept>> multiples = new TreeMap; for (S field : conceptFields(c)) { O val = cget(c, field); if (!val << Concept) simples.put(field, val); else { L<Concept> l = unrollOptions(val/Concept); if (empty(l)) ret ll(); else if (l(l) == 1) simples.put(field, first(l)); else multiples.put(field, l); } } final Concept d = unlisted(c.getClass()); csetMap(d, simples); if (empty(multiples)) ret ll(d); else { if (l(multiples) > 2) warn("todo johnny"); new L out; L<S> fields = asList(keys(multiples)); S field0 = fields.get(0); for (Concept value0 : multiples.get(field0)) { Concept e = unlisted(c.getClass()); copyConceptFields(d, e); cset(e, field0, value0); if (l(multiples) == 1) out.add(e); else { S field1 = fields.get(1); for (Concept value1 : multiples.get(field1)) { Concept f = unlisted(c.getClass()); copyConceptFields(e, f); cset(f, field1, value1); out.add(f); } } } ret out; } } }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1005496 |
Snippet name: | unrollOptions |
Eternal ID of this version: | #1005496/1 |
Text MD5: | 5a02d0e2cba61ec37eb10c1c0e2ba296 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-11-23 14:51:08 |
Source code size: | 1508 bytes / 52 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 501 / 524 |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |