Search in sources :

Example 1 with CompileGeneralizerImpl

use of suite.lp.compile.impl.CompileGeneralizerImpl in project suite by stupidsing.

the class GeneralizerFactoryTest method test.

private void test(String pattern, String match) {
    for (GeneralizerFactory gf : new GeneralizerFactory[] { new CompileGeneralizerImpl(), new SewingGeneralizerImpl() }) {
        Generalize_ p = gf.generalizer(Suite.parse(pattern));
        assertTrue(Binder.bind(p.apply(gf.mapper().env()), Suite.parse(match), new Trail()));
    }
}
Also used : CompileGeneralizerImpl(suite.lp.compile.impl.CompileGeneralizerImpl) Trail(suite.lp.Trail) Generalize_(suite.lp.doer.GeneralizerFactory.Generalize_) SewingGeneralizerImpl(suite.lp.sewing.impl.SewingGeneralizerImpl)

Example 2 with CompileGeneralizerImpl

use of suite.lp.compile.impl.CompileGeneralizerImpl in project suite by stupidsing.

the class CommandDispatcher method elaborate.

private void elaborate(Node node0, Sink<Node> sink) {
    int[] count = { 0 };
    NodeEnv<Atom> ne = new CompileGeneralizerImpl().g(node0).source();
    Node node1 = ne.node;
    Node elab = new Data<Source<Boolean>>(() -> {
        String dump = ne.dumpVariables();
        if (!dump.isEmpty())
            opt.prompt().println(dump);
        count[0]++;
        return Boolean.FALSE;
    });
    sink.sink(Tree.of(TermOp.AND___, node1, elab));
    if (count[0] == 1)
        opt.prompt().println(count[0] + " solution\n");
    else
        opt.prompt().println(count[0] + " solutions\n");
}
Also used : CompileGeneralizerImpl(suite.lp.compile.impl.CompileGeneralizerImpl) Node(suite.node.Node) Data(suite.node.Data) Atom(suite.node.Atom)

Aggregations

CompileGeneralizerImpl (suite.lp.compile.impl.CompileGeneralizerImpl)2 Trail (suite.lp.Trail)1 Generalize_ (suite.lp.doer.GeneralizerFactory.Generalize_)1 SewingGeneralizerImpl (suite.lp.sewing.impl.SewingGeneralizerImpl)1 Atom (suite.node.Atom)1 Data (suite.node.Data)1 Node (suite.node.Node)1