Package net.fortytwo.ripple.model

Examples of net.fortytwo.ripple.model.RippleList


    }

    public void apply(final RippleList arg,
                      final Sink<RippleList> solutions,
                      final ModelConnection mc) throws RippleException {
        RippleList stack = arg;
        String str, substr;
        int result;

        substr = mc.toString(stack.getFirst());
        stack = stack.getRest();
        str = mc.toString(stack.getFirst());
        stack = stack.getRest();

        result = str.indexOf(substr);
        solutions.put(
                stack.push(mc.valueOf(result)));
    }
View Full Code Here


    public void apply(final RippleList arg,
                      final Sink<RippleList> solutions,
                      final ModelConnection mc) throws RippleException {

        RippleList stack = arg;

        RippleValue l;

        final RippleValue f = stack.getFirst();
        stack = stack.getRest();
        final RippleValue v = stack.getFirst();
        stack = stack.getRest();
        l = stack.getFirst();
        final RippleList rest = stack.getRest();

        Sink<RippleList> listSink = new Sink<RippleList>() {
            public void put(final RippleList list) throws RippleException {
                //RippleList lList = list.invert();
                RippleList lList = list;
                RippleList result = rest.push(v);

                while (!lList.isNil()) {
                    result = result.push(lList.getFirst())
                            .push(f)
                            .push(Operator.OP);
                    lList = lList.getRest();
                }
View Full Code Here

    }

    public void apply(final RippleList arg,
                      final Sink<RippleList> solutions,
                      final ModelConnection mc) throws RippleException {
        RippleList stack = arg;

        RippleValue regex, replacement, s;
        String result;

        replacement = stack.getFirst();
        stack = stack.getRest();
        regex = stack.getFirst();
        stack = stack.getRest();
        s = stack.getFirst();
        stack = stack.getRest();

        try {
            result = mc.toString(s).replaceAll(mc.toString(regex), mc.toString(replacement));
        } catch (java.util.regex.PatternSyntaxException e) {
            // Hard fail (for now).
            throw new RippleException(e);
        }

        solutions.put(
                stack.push(StringLibrary.value(result, mc, replacement, regex, s)));

    }
View Full Code Here

    public void apply(final RippleList arg,
                      final Sink<RippleList> solutions,
                      final ModelConnection mc) throws RippleException {

        RippleList stack = arg;
        boolean x, y;

        x = mc.toBoolean(stack.getFirst());
        stack = stack.getRest();
        y = mc.toBoolean(stack.getFirst());
        stack = stack.getRest();

        RippleValue result = mc.valueOf(x || y);

        solutions.put(
                stack.push(result));
    }
View Full Code Here

            RippleValue first = arg.getFirst();
            //System.out.println( "   first.isActive() = " + first.isActive() );
            //System.out.println("   first = " + stack.getFirst());

            if (null != first.getMapping()) {
                RippleList rest = arg.getRest();
                //System.out.println("   rest = " + rest);

                final StackMapping f = first.getMapping();
                //System.out.println("   f = " + f);
                //System.out.println("   f.arity() = " + f.arity());

                // Nullary functions don't need their argument stacks reduced.
                // They shouldn't even care if the stack is empty.
                if (f.arity() == 0) {
                    f.apply(rest, this, mc);
                }

                // Functions with positive arity do require the stack to be
                // reduced, to one level per argument.
                else {
                    // We simply ignore stacks which can't be reduced to
                    // something with a passive item on top.
                    if (rest.isNil()) {
                        // sink.put( stack );
                    } else {
                        final Sink<RippleList> thisEval = this;
                        Sink<RippleList> argSink = new Sink<RippleList>() {
                            public void put(final RippleList arg) throws RippleException {
View Full Code Here

            public void apply(final RippleList arg,
                              final Sink<RippleList> solutions,
                              final ModelConnection mc) throws RippleException {

                RippleList stack = arg;

                boolean x;

                x = mc.toBoolean(stack.getFirst());
                stack = stack.getRest();

                if (x) {
                    RippleValue t = mc.valueOf(true);
                    RippleValue f = mc.valueOf(false);
                    solutions.put(stack.push(t).push(t));
                    solutions.put(stack.push(t).push(f));
                    solutions.put(stack.push(f).push(t));
                } else {
                    RippleValue f = mc.valueOf(false);
                    solutions.put(stack.push(f).push(f));
                }
            }
        };
    }
View Full Code Here

    public void apply(final RippleList arg,
                      final Sink<RippleList> solutions,
                      final ModelConnection mc) throws RippleException {

        RippleList stack = arg;

        final int min, max;

        max = mc.toNumericValue(stack.getFirst()).intValue();
        stack = stack.getRest();
        min = mc.toNumericValue(stack.getFirst()).intValue();
        stack = stack.getRest();
        RippleValue p = stack.getFirst();
        final RippleList rest = stack.getRest();

        Sink<Operator> opSink = new Sink<Operator>() {
            public void put(final Operator op) throws RippleException {
                solutions.put(rest.push(
                        new StackMappingWrapper(new TimesQuantifier(op, min, max), mc)));
            }
        };

        Operator.createOperator(p, opSink, mc);
View Full Code Here

    }

    public void apply(final RippleList arg,
                      final Sink<RippleList> solutions,
                      final ModelConnection mc) throws RippleException {
        RippleList stack = arg;

        String b = mc.toString(stack.getFirst());
        stack = stack.getRest();
        String a = mc.toString(stack.getFirst());
        stack = stack.getRest();

        RDFValue result = mc.valueOf(a.contains(b));

        solutions.put(
                stack.push(result));
    }
View Full Code Here

    }

    public void apply(final RippleList arg,
                      final Sink<RippleList> solutions,
                      final ModelConnection mc) throws RippleException {
        RippleList stack = arg;

        RippleValue a = stack.getFirst();
        stack = stack.getRest();

        String result = StringUtils.sha1SumOf(mc.toString(a));
        solutions.put(
                stack.push(StringLibrary.value(result, mc, a)));
    }
View Full Code Here

    public void apply(final RippleList arg,
                      final Sink<RippleList> solutions,
                      final ModelConnection mc) throws RippleException {

        RippleList stack = arg;
        boolean x;

        x = mc.toBoolean(stack.getFirst());
        stack = stack.getRest();

        RippleValue result = mc.valueOf(!x);

        solutions.put(
                stack.push(result));
    }
View Full Code Here

TOP

Related Classes of net.fortytwo.ripple.model.RippleList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.