Examples of ExprArray


Examples of org.boris.expr.ExprArray

        int rows = 1;
        if (cols == -1)
            cols = args.size();
        else
            rows = args.size() / cols;
        ExprArray a = new ExprArray(rows, cols);
        for (int i = 0; i < args.size(); i++) {
            a.set(0, i, (Expr) args.get(i));
        }

        setValue(a);
    }
View Full Code Here

Examples of org.boris.expr.ExprArray

        }
    }

    protected Expr get(Expr range, int index) {
        if (range instanceof ExprArray) {
            ExprArray a = (ExprArray) range;
            if (index >= 0 && index < a.length()) {
                return a.get(index);
            }
        } else if (index == 0) {
            return range;
        }
View Full Code Here

Examples of org.boris.expr.ExprArray

        if (strict)
            throw new ExprException("Argument not an array for function: " +
                    getClass().getSimpleName());

        ExprArray ea = new ExprArray(1, 1);
        ea.set(0, expr);
        return ea;
    }
View Full Code Here

Examples of org.boris.expr.ExprArray

        return a;
    }

    public static ExprArray toArray(Object... args) {
        Expr[] a = Exprs.convertArgs(args);
        ExprArray arr = new ExprArray(1, a.length);
        for (int i = 0; i < a.length; i++) {
            arr.set(0, i, a[i]);
        }
        return arr;
    }
View Full Code Here

Examples of org.boris.expr.ExprArray

        int y2 = dim2 == null ? y1 : dim2.getRow();
        int width = x2 - x1 + 1;
        int height = y2 - y1 + 1;
        assert (width > 0);
        assert (height > 0);
        ExprArray arr = new ExprArray(height, width);
        for (int i = 0; i < width; i++) {
            for (int j = 0; j < height; j++) {
                arr.set(j, i, get(x1 + i, y1 + j));
            }
        }

        return arr;
    }
View Full Code Here

Examples of org.boris.expr.ExprArray

        rows++;
    }

    public ExprArray toArray() {
        ExprArray a = new ExprArray(rows, cols);
        for (int i = 0; i < a.length(); i++) {
            a.set(i, values.get(i));
        }
        return a;
    }
View Full Code Here

Examples of org.boris.expr.ExprArray

    double[] asArray(Expr vals) throws ExprException {
        if (vals instanceof ExprInteger || vals instanceof ExprDouble) {
            return new double[] { ((ExprNumber) vals).doubleValue() };
        } else if (vals instanceof ExprArray) {
            ExprArray a = (ExprArray) vals;
            double[] arr = new double[a.length()];
            int index = 0;
            for (int i = 0; i < arr.length; i++) {
                Expr e = evalArg(a.get(i));
                if (e instanceof ExprNumber) {
                    arr[index++] = ((ExprNumber) e).doubleValue();
                }
            }
            if (arr.length == index)
View Full Code Here

Examples of org.boris.expr.ExprArray

        if (e instanceof ExprEvaluatable) {
            e = ((ExprEvaluatable) e).evaluate();
        }

        if (e instanceof ExprArray) {
            ExprArray a = (ExprArray) e;
            Expr[] ai = a.getArgs();
            for (Expr aie : ai) {
                evalItem(aie, c);
                if (!c.doit)
                    break;
            }
View Full Code Here

Examples of org.boris.expr.ExprArray

public class COUNTIF extends AbstractFunction
{
    public Expr evaluate(Expr[] args) throws ExprException {
        assertArgCount(args, 2);
        // TODO assert first argument as reference
        ExprArray array = asArray(args[0], true);
        Condition cond = Condition.valueOf(args[1]);
        if (cond == null)
            return ExprError.VALUE;
        Expr[] a = array.getArgs();
        int count = 0;
        for (int i = 0; i < a.length; i++) {
            if (cond.eval(a[i]))
                count++;
        }
View Full Code Here

Examples of org.boris.expr.ExprArray

        if (arg instanceof ExprDouble || arg instanceof ExprInteger) {
            return 1;
        } else if (arg instanceof ExprArray) {
            int count = 0;
            ExprArray arr = (ExprArray) arg;
            int rows = arr.rows();
            int cols = arr.columns();
            for (int i = 0; i < rows; i++) {
                for (int j = 0; j < cols; j++) {
                    count += count(arr.get(i, j), any);
                }
            }
            return count;
        } else {
            if (any) {
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.