public IExpr getAt(final int index) { return get(index); }
/** {@inheritDoc} */ public boolean isAST(final IExpr header) { return get(0).equals(header); }
/** * Casts an <code>IExpr</code> at position <code>index</code> to an * <code>IInteger</code>. * * @param index * @return * @throws WrongArgumentType * if the cast is not possible */ public IInteger getInt(int index) { if (get(index) instanceof IInteger) { return (IInteger) get(index); } throw new WrongArgumentType(this, get(index), index); }
/** * Casts an <code>IExpr</code> at position <code>index</code> to an * <code>IAST</code>. * * @param index * @return * @throws WrongArgumentType * if the cast is not possible */ public IAST getAST(int index) { if (get(index) instanceof IAST) { return (IAST) get(index); } throw new WrongArgumentType(this, get(index), index); }
/** * {@inheritDoc} */ public boolean isAST(final String symbol) { return get(0).toString().equals(symbol); }
/** * Casts an <code>IExpr</code> which is a list at position <code>index</code> * to an <code>IAST</code>. * * @param index * @return * @throws WrongArgumentType */ public IAST getList(int index) { if (get(index).isList()) { return (IAST) get(index); } throw new WrongArgumentType(this, get(index), index); }
/** * {@inheritDoc} */ public boolean isAST(final IExpr header, final int length) { return (size() == length) && get(0).equals(header); }
/** * {@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); }
public IAST copyHead() { return newInstance(get(0)); }
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; }
public IAST apply(final IExpr head, final int start, final int end) { final IAST ast = F.ast(head); for (int i = start; i < end; i++) { ast.add(get(i)); } return ast; }
public IExpr evaluate(int[] index) { return Power(lst.get(index[0] + 1), IntegerSym.valueOf(index[1])); } };
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; }
public boolean isSlotSequence() { return size() == 2 && head().equals(F.SlotSequence) && get(1).isInteger(); }
/** * Signum functionality is used in JAS toString() method, don't use it as math * signum function. * * @deprecated */ @Override public int signum() { if (isTimes()) { IExpr temp = get(1); if (temp.isSignedNumber() && ((ISignedNumber) temp).isNegative()) { return -1; } } return 1; }
/** * Plots shape number f, and sets its color. */ protected void doPlot(final IAST funcs, final int f, final EvalEngine engine) { if (((AST) funcs.get(f + 1)).size() < 3) { throw new IllegalArgumentException("Two functions required for plot #" + f); } x = new UnaryNumerical(((AST) funcs.get(f + 1)).get(1), t, engine); y = new UnaryNumerical(((AST) funcs.get(f + 1)).get(2), t, engine); for (int counter = 0; counter <= thisResolution; ++counter) { plotPoint(f, counter); } colorPlot(funcs, f); }
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; }
private int compareToAST(final AST ast) { // compare the headers of the 2 expressions: int cp = head().compareTo(ast.head()); if (cp != 0) { return cp; } final int commonArgSize = (size() > ast.size()) ? ast.size() : size(); for (int i = 1; i < commonArgSize; i++) { cp = get(i).compareTo(ast.get(i)); if (cp != 0) { return cp; } } return size() - ast.size(); }