Examples of RippleList


Examples of net.fortytwo.ripple.model.RippleList

    public void evaluate(final Sink<RippleList> sink,
                         final QueryEngine qe,
                         final ModelConnection mc)
            throws RippleException {
        RippleList l;

        switch (type) {
            case Apply:
                l = mc.list().push(Operator.OP);
                break;
View Full Code Here

Examples of net.fortytwo.ripple.model.RippleList

    }

    private double compare(final String expr1, final String expr2) throws Exception {
        Collection<RippleList> results = reduce(expr1 + " " + expr2 + " compare.");
        assertEquals(1, results.size());
        RippleList l = results.iterator().next();
        assertEquals(1, l.length());
        RippleValue v = l.getFirst();
        assertTrue(v instanceof NumericValue);
        return ((NumericValue) v).doubleValue();
    }
View Full Code Here

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;
        RippleValue first = stack.getFirst();
        stack = stack.getRest();

        if (first instanceof KeyValueValue) {
            for (String key : ((KeyValueValue) first).getKeys()) {
                RippleValue value = ((KeyValueValue) first).getValue(key, mc);
                solutions.put(stack.push(mc.valueOf(key)).push(value));
            }
        }
    }
View Full Code Here

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;

        NumericValue a, result;

        a = mc.toNumericValue(stack.getFirst());
        stack = stack.getRest();

        result = mc.valueOf(Math.cbrt(a.doubleValue()));

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

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;
        RippleValue first = 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 StarQuantifier(op), mc)));
            }
        };

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

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;

        final int index = mc.toNumericValue(stack.getFirst()).intValue();
        stack = stack.getRest();
        RippleValue l = stack.getFirst();
        final RippleList rest = stack.getRest();

        Sink<RippleList> listSink = new Sink<RippleList>() {
            public void put(RippleList list) throws RippleException {
                if (list.isNil()) {
                    throw new RippleException("list index out of bounds: " + index);
                }

                if (index < 1) {
                    throw new RippleException("list index out of bounds (note: 'at' begins counting at 1): " + index);
                }

                for (int j = 1; j < index; j++) {
                    list = list.getRest();
                    if (list.isNil()) {
                        throw new RippleException("list index out of bounds: " + index);
                    }
                }

                solutions.put(
                        rest.push(list.getFirst()));
            }
        };

        mc.toList(l, listSink);
    }
View Full Code Here

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;

            NumericValue a, result;

            a = mc.toNumericValue(stack.getFirst());
            stack = stack.getRest();

            result = a.mul(a).mul(a);

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

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;

        int begin, end;
        RippleValue s;
        String result;

        end = mc.toNumericValue(stack.getFirst()).intValue();
        stack = stack.getRest();
        begin = mc.toNumericValue(stack.getFirst()).intValue();
        stack = stack.getRest();
        s = stack.getFirst();
        stack = stack.getRest();

        try {
            result = mc.toString(s).substring(begin, end);
            solutions.put(
                    stack.push(StringLibrary.value(result, mc, s)));
        } catch (IndexOutOfBoundsException e) {
            // Silent fail.
        }
    }
View Full Code Here

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;
        RippleValue l;

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

        Sink<RippleList> listSink = new Sink<RippleList>() {
            public void put(final RippleList list) throws RippleException {
                solutions.put(
                        rest.push(list.push(x)));
            }
        };

        mc.toList(l, listSink);
    }
View Full Code Here

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;
        RippleValue mapping = stack.getFirst();
        final RippleList rest = stack.getRest();

        Sink<Operator> opSink = new Sink<Operator>() {
            public void put(final Operator op) throws RippleException {
                CriterionApplicator applicator = new CriterionApplicator(op);
                solutions.put(rest.push(new Operator(applicator)));
            }
        };

        Operator.createOperator(mapping, opSink, mc);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.