public static AST newInstance(final IExpr head) { AST ast = new AST(5, false); ast.append(head); return ast; }
/** {@inheritDoc} */ @Override public IASTAppendable copyFrom(int index) { AST result = new AST(size() - index + 1, false); result.append(head()); result.appendAll(this, index, size()); return result; }
/** * * @param intialCapacity * the initial capacity (i.e. number of arguments without the header element) of the list. * @param head * @return */ public static AST newInstance(final int intialCapacity, final IExpr head) { AST ast = new AST(intialCapacity + 1, false); ast.append(head); return ast; }
/** * Create a new abstract syntax tree (AST). * * @param head * the header expression of the function. If the ast represents a function like * <code>f[x,y], Sin[x],...</code>, the <code>head</code> will be an instance of type ISymbol. * @param initialCapacity * the initial capacity (i.e. number of arguments without the header element) of the list. * @param initNull * initialize all elements with <code>null</code>. * @return */ public static IASTAppendable ast(final IExpr head, final int initialCapacity, final boolean initNull) { final AST ast = AST.newInstance(initialCapacity, head); if (initNull) { for (int i = 0; i < initialCapacity; i++) { ast.append(null); } } return ast; }
/** * Creates a new AST from the given <code>ast</code> and <code>head</code>. if <code>include</code> is set to * <code>true </code> all arguments from index first to last-1 are copied in the new list if <code>include</code> is * set to <code> false </code> all arguments excluded from index first to last-1 are copied in the new list * */ public static IAST ast(final IAST f, final IExpr head, final boolean include, final int first, final int last) { AST ast = null; if (include) { ast = AST.newInstance(last - first, head); // range include for (int i = first; i < last; i++) { ast.append(f.get(i)); } } else { ast = AST.newInstance(f.size() - last + first - 1, head); // range exclude for (int i = 1; i < first; i++) { ast.append(f.get(i)); } for (int j = last; j < f.size(); j++) { ast.append(f.get(j)); } } return ast; }