/** * {@inheritDoc} */ public boolean isCondition() { return size() == 3 && head().equals(F.Condition); }
/** * {@inheritDoc} */ public boolean isAST(final IExpr header, final int length) { return (size() == length) && get(0).equals(header); }
/** * {@inheritDoc} */ public boolean isFunction() { return size() >= 2 && head().equals(F.Function); }
/** * Get the range of elements [start..sizeOfAST[ of the AST * * @return */ public ASTRange range(final int start) { return new ASTRange(this, start, size()); }
public List<IExpr> leaves() { int sz = size(); if (sz < 2) { return java.util.Collections.EMPTY_LIST; } return subList(1, sz); }
/** * {@inheritDoc} */ public boolean isModule() { return size() == 3 && head().equals(F.Module); }
/** * {@inheritDoc} */ public boolean isASTSizeGE(final IExpr header, final int length) { return (size() >= length) && get(0).equals(header); }
/** * {@inheritDoc} */ public boolean isAST(final String symbol, final int length) { return (size() == length) && get(0).toString().equals(symbol); }
/** * Get the range of elements [0..sizeOfAST[ of the AST * * @return */ public ASTRange range() { return new ASTRange(this, 0, size()); }
public boolean isCosh() { return size() == 2 && head().equals(F.Cosh); }
/** {@inheritDoc} */ public boolean isRuleAST() { return size() == 3 && (head().equals(F.Rule) || head().equals(F.RuleDelayed)); }
/** * {@inheritDoc} */ public boolean addAll(List<? extends IExpr> ast, int startPosition, int endPosition) { if (ast.size() > 0 && startPosition < endPosition) { ensureCapacity(size() + (endPosition - startPosition)); for (int i = startPosition; i < endPosition; i++) { add(ast.get(i)); } return true; } return false; }
public IAST map(final IAST resultAST, final Function<IExpr, IExpr> function) { IExpr temp; for (int i = 1; i < size(); i++) { temp = function.apply(get(i)); if (temp != null) { resultAST.set(i, temp); } } return resultAST; }
/** * {@inheritDoc} */ public IAST filter(IAST filterAST, IAST restAST, Predicate<IExpr> predicate) { return (new ASTRange(this, 1, size())).filter(filterAST, restAST, predicate); }
/** * {@inheritDoc} */ public IAST filter(IAST filterAST, Predicate<IExpr> predicate) { return (new ASTRange(this, 1, size())).filter(filterAST, predicate); }
public boolean isListOfLists() { if (head().equals(F.List)) { for (int i = 2; i < size(); i++) { if (!get(i).isList()) { // the row is no list return false; } } return true; } return false; }
/** * {@inheritDoc} */ public IAST[] split(final Function<IExpr, IExpr> function) { IAST[] result = new IAST[2]; result[0] = copyHead(); result[1] = copyHead(); new ASTRange(this, 1, size()).filter(result[0], result[1], function); return result; }
public IAST map(IAST resultAST, IAST secondAST, BiFunction<IExpr, IExpr, IExpr> function) { for (int i = 1; i < size(); i++) { resultAST.add(function.apply(get(i), secondAST.get(i))); } return resultAST; }
/** * {@inheritDoc} */ public IAST[] split(Predicate<IExpr> predicate) { IAST[] result = new IAST[2]; result[0] = copyHead(); result[1] = copyHead(); new ASTRange(this, 1, size()).filter(result[0], result[1], predicate); return result; }