!7 !include once #1017126 // transpileRaw sclass DevelopFromExamples > DynTextArea { S whatToTry; transient ReliableSingleThread rst = new(r think); JComponent visualize() { ret withCenteredButtons(centerAndSouthWithMargins( jhsplit(super.visualize(), dm_printLogComponent()), jsection("Stuff to try", dm_fieldTextField('whatToTry))), "Think", rst); } void think { loadFunctions_preferDiskCache(); S text = rtrimAll(getText()); Pair examplesFile = ai_makeExamplesFile(text); if (examplesFile.b) print("Wrote: " + f2s(examplesFile.a)); new L> examples; for (S line : tlftj(text)) pcall { L l = splitAtDoubleArrow_bothDirections(line); if (l(l) == 2) addPair(examples, first(l), second(l)); } print("Thinking about " + n2(examples, "example")); new LinkedHashSet thingsThatWork; for (fS s : words(whatToTry)) if (isStandardFunction(s)) { F1 f = func(S in) -> S { struct(callAndMake_orDirect(s, unstruct(in))) }; if (worksOnAllExamples(f, examples)) print("WORKS: " + addAndReturn(thingsThatWork, s)); else print("Nope: " + s); } print("Done. " + (empty(thingsThatWork) ? "Nothing works." : "Things that work: " + joinWithComma(thingsThatWork))); } }