!759 !include #1005325 // Logic 4 concept AtEachPointInTime { new Ref what; public S toString() { ret shortClassName(this) + " " + what; } } concept ItIs { new Ref what; public S toString() { ret shortClassName(this) + " " + what; } } concept ExactlyOne { new Ref what; public S toString() { ret shortClassName(this) + " " + what; } } concept Which { new Ref what; public S toString() { ret shortClassName(this) + " " + what; } } concept Weekday { public S toString() { ret shortClassName(this); } } p { truly(AtEachPointInTime, uniq(ItIs, uniq(ExactlyOne, uniq(Weekday)))); for (AtEachPointInTime statement : listActually(AtEachPointInTime)) { print("Right now: " + statement.what); Concept question = exactlyOneToWhich(statement.what!); print("Question thus: " + question); } saveConcepts(); } static Concept exactlyOneToWhich(Concept c) { // conversion case we are looking for if (c instanceof ExactlyOne) ret cnew(Which, "what", exactlyOneToWhich((Concept) cget(c, "what"))); // general recurse L refs = c.refs; if (l(refs) == 0) ret c; // no references in it, keep original // clone and process references Concept c2 = cnew(_getClass(c)); Collection names = getRefNames(c); for (S name : names) cset(c2, name, exactlyOneToWhich((Concept) cget(c, name))); ret c2; }