!752 concepts. concept Yo { new Ref a; *() {} *(Concept c) { a.set(c); } } concept YoYo { new Ref a; new Ref b; *() {} *(Concept a, Concept b) { this.a.set(a); this.b.set(b); } } p { Concept a = new Yo, b = cstr("yo"); check(ll(a), a); check(ll(), new Options); check(ll(a), new Options(a)); check(ll(a, b), new Options(a, b)); check(ll(), new Yo(new Options())); check(ll(new Yo(a)), new Yo(new Options(a))); check(ll(new Yo(a)), new Yo(new Options(new Options(a)))); check(ll(new YoYo(a, b)), new YoYo(a, b)); check(ll(new YoYo(a, b), new YoYo(b, b)), new YoYo(new Options(a, b), b)); check(ll(new YoYo(a, b), new YoYo(a, a)), new YoYo(a, new Options(b, a))); check(ll(new YoYo(a, b), new YoYo(a, a), new YoYo(b, b), new YoYo(b, a)), new YoYo(new Options(a, b), new Options(b, a))); } static L 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 simples; Map> multiples = new TreeMap; for (S field : conceptFields(c)) { O val = cget(c, field); if (!val << Concept) simples.put(field, val); else { L 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 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; } } } svoid check(L l, Concept in) { L l2 = unrollOptions(in); /*assertEquals(l(l), l(l2)); for i over l: assertEquals(conceptStructure((Concept) l.get(i)), conceptStructure(l2.get(i))); print("ok");*/ assertEqualsVerbose(conceptStructure(unlistedConceptL(l)), conceptStructure(unlistedConceptL(l2))); }