IAST
org.matheclipse.core.interfaces

Interface IAST

  • All Superinterfaces:
    AbelianGroupElem<IExpr>, Cloneable, Collection<IExpr>, Comparable<IExpr>, Element<IExpr>, IExpr, Iterable<IExpr>, List<IExpr>, MonoidElem<IExpr>, RingElem<IExpr>, Serializable
    All Known Implementing Classes:
    AST


    public interface IASTextends IExpr, List<IExpr>, Cloneable

    (I)nterface for the (A)bstract (S)yntax (T)ree of a given function.

    In MathEclipse, an abstract syntax tree (AST), is a tree representation of the abstract syntactic structure of the MathEclipse source code. Each node of the tree denotes a construct occurring in the source code. The syntax is 'abstract' in the sense that it does not represent every detail that appears in the real syntax. For instance, grouping parentheses are implicit in the tree structure, and a syntactic construct such as a Sin[x] expression will be denoted by an AST with 2 nodes. One node for the header Sin and one node for the argument x.

    Internally an AST is represented as a java.util.List which contains
    • the operator of a function (i.e. the "header"-symbol: Sin, Cos, Inverse, Plus, Times,...) at index 0 and
    • the n arguments of a function in the index 1 to n
    See Abstract syntax tree.
    • Field Detail

      • CONTAINS_PATTERN

        static final int CONTAINS_PATTERN
        The head or one of the arguments of the list or sublists contains a pattern object
        See Also:
        Constant Field Values
      • CONTAINS_PATTERN_SEQUENCE

        static final int CONTAINS_PATTERN_SEQUENCE
        The head or one of the arguments of the list or sublists contains a pattern object
        See Also:
        Constant Field Values
      • CONTAINS_DEFAULT_PATTERN

        static final int CONTAINS_DEFAULT_PATTERN
        One of the arguments of the list contains a pattern object which can be set to a default value.
        See Also:
        Constant Field Values
      • CONTAINS_PATTERN_EXPR

        static final int CONTAINS_PATTERN_EXPR
        One of the arguments of the list or sublists contains a pattern object. Combination of CONTAINS_PATTERN, CONTAINS_PATTERN_SEQUENCE, CONTAINS_DEFAULT_PATTERN
        See Also:
        Constant Field Values
      • CONTAINS_NO_DEFAULT_PATTERN_MASK

        static final int CONTAINS_NO_DEFAULT_PATTERN_MASK
        Negative flag mask for CONTAINS_DEFAULT_PATTERN
        See Also:
        Constant Field Values
      • IS_MATRIX_OR_VECTOR

        static final int IS_MATRIX_OR_VECTOR
        This expression represents a matrix or vector if one of the following bits is set.
        See Also:
        Constant Field Values
      • IS_DECOMPOSED_PARTIAL_FRACTION

        static final int IS_DECOMPOSED_PARTIAL_FRACTION
        This expression represents an already decomposed partial fraction
        See Also:
        Apart, Constant Field Values
      • IS_FLATTENED

        static final int IS_FLATTENED
        This expression is an already flattened expression
        See Also:
        Constant Field Values
      • IS_SORTED

        static final int IS_SORTED
        This expression is an already sorted expression
        See Also:
        Constant Field Values
      • IS_LISTABLE_THREADED

        static final int IS_LISTABLE_THREADED
        This expression has already applied the Listable attribute to its argument expressions
        See Also:
        Constant Field Values
      • IS_FLATTENED_OR_SORTED_MASK

        static final int IS_FLATTENED_OR_SORTED_MASK
        This expression is an already flattened or sorted expression
        See Also:
        Constant Field Values
    • Method Detail

      • getEvalFlags

        int getEvalFlags()
        Get the evaluation flags for this list.
        Returns:
      • topHead

        ISymbol topHead()
        Returns the header. If the header itself is an ISymbol it will return the symbol object. If the header itself is an IAST it will recursively call headSymbol(). If the head is of type INumbers, the head will return one of these headers: "DoubleComplex", "Double", "Integer", "Fraction", "Complex". All other objects return null.
        Specified by:
        topHead in interface IExpr
        Returns:
        the 'highest level' head of the expression, before Symbol, Integer, Real or String. for example while the head of a[b][c] is a[b], the top head is a.
      • isEvalFlagOff

        boolean isEvalFlagOff(int i)
        Are the given evaluation flags disabled for this list ?
        Returns:
      • isEvalFlagOn

        boolean isEvalFlagOn(int i)
        Are the given evaluation flags enabled for this list ?
        Returns:
      • setEvalFlags

        void setEvalFlags(int i)
        Set the evaluation flags for this list.
        Parameters:
        i -
      • addEvalFlags

        void addEvalFlags(int i)
        Add an evaluation flag to the existing ones.
        Parameters:
        i -
      • addOneIdentity

        IAST addOneIdentity(IAST subAST)
        Add an subAST with attribute OneIdentity for example Plus[] or Times[].
        Parameters:
        subAST - an ast with attribute OneIdentity.
        Returns:
        this ast after adding the subAST
      • getOneIdentity

        IExpr getOneIdentity(IExpr defaultValue)
        Get the argument at index 1, if the size() == 2 or the complete ast if the size() > 2 (useful for ASTs with attribute OneIdentity for example for Plus[] you can call getOneIdentity(F.C0) or for Times[]) you can call getOneIdentity(F.C1).
        Parameters:
        defaultValue - default value, if size() < 2.
        Returns:
      • addAll

        boolean addAll(List<? extends IExpr> ast,             int startPosition,             int endPosition)
        Appends all elements from offset startPosition to endPosition in the specified AST to the end of this AST.
        Parameters:
        ast - AST containing elements to be added to this AST
        startPosition - the start position, inclusive.
        endPosition - the ending position, exclusive.
        Returns:
        true if this AST changed as a result of the call
        See Also:
        List.add(Object)
      • addAll

        boolean addAll(List<? extends IExpr> ast)
        Appends all of the arguments (starting from offset 1) in the specified AST to the end of this AST.
        Parameters:
        ast - AST containing elements to be added to this AST
        Returns:
        true if this AST changed as a result of the call
        See Also:
        List.add(Object)
      • isList

        boolean isList()
        Is this a list (i.e. with header == List)
        Specified by:
        isList in interface IExpr
        Returns:
      • isPlus

        boolean isPlus()
        Test if this expression is the addition function Plus[<arg1>, <arg2>, ...]
        Specified by:
        isPlus in interface IExpr
      • isPower

        boolean isPower()
        Test if this expression is the function Power[<arg1>, <arg2>]
        Specified by:
        isPower in interface IExpr
      • isTimes

        boolean isTimes()
        Test if this expression is the multiplication function Times[<arg1>, <arg2>, ...]
        Specified by:
        isTimes in interface IExpr
      • iterator0

        Iterator<IExpr> iterator0()
        Returns an iterator over the elements in this list starting with offset 0.
        Returns:
        an iterator over this list values.
      • arg1

        IExpr arg1()
        Get the first argument (i.e. the second element of the underlying list structure) of the AST function (i.e. get(1) ).
        Returns:
        the first argument of the function represented by this AST.
        See Also:
        IExpr.head()
      • arg2

        IExpr arg2()
        Get the second argument (i.e. the third element of the underlying list structure) of the AST function (i.e. get(2) ).
        Returns:
        the second argument of the function represented by this AST.
        See Also:
        IExpr.head()
      • arg3

        IExpr arg3()
        Get the third argument (i.e. the fourth element of the underlying list structure) of the AST function (i.e. get(3) ).
        Returns:
        the third argument of the function represented by this AST.
        See Also:
        IExpr.head()
      • last

        IExpr last()
        Get the last element of the AST list (i.e. get(size()-1).
        Returns:
        the last argument of the function represented by this AST.
        See Also:
        IExpr.head()
      • apply

        IAST apply(IExpr head)
        Apply the given head to this expression (i.e. create a list clone and replace the old head with the given one)
        Parameters:
        head -
        Returns:
      • apply

        IAST apply(IExpr head,         int start)
        Apply the given head to this expression (i.e. create a sublist clone starting from index start and replacing the old head with the given one)
        Parameters:
        head -
        Returns:
      • apply

        IAST apply(IExpr head,         int start,         int end)
        Apply the given head to this expression (i.e. create a sublist clone from index start to end, and replacing the old head with the given one)
        Parameters:
        head -
        Returns:
      • map

        IAST map(Function<IExpr,IExpr> functor)
        Maps the elements of this IAST with the unary functor. If the function returns null the original element is used (i.e. the functor didn't modified this AST).

        Example for mapping with Functors#replace1st(), where the first argument will be replaced by the current argument of this AST:
         plusAST.map(Functors.replace1st(F.D(F.Null, dAST.get(2)))); 
        Parameters:
        functor - a unary function
        Returns:
      • map

        IAST map(IExpr head,       Function<IExpr,IExpr> functor)
        Maps the elements of this IAST with the unary functor. If the function returns null the original element of the result list is used.
        Parameters:
        head - the new head element of the result list
        functor - a unary function
        Returns:
      • map

        IAST map(IAST clonedResultAST,       Function<IExpr,IExpr> functor)
        Maps the elements of this IAST with the unary functor. If the function returns null the original element of the result list is used.
        Parameters:
        clonedResultAST - a list which is cloned from this list or greater or equal in size of this list.
        functor - a unary function
        Returns:
      • filter

        IAST filter(IAST filterAST,          Predicate<IExpr> predicate)
        Apply the predicate to each element in this AST and append the elements which satisfy the predicate to the filterAST.
        Parameters:
        filterAST - the elements which satisfy the predicate
        predicate - the predicate which filters each element in the range
        Returns:
        the filterList
      • filter

        IAST filter(IAST filterAST,          IAST restAST,          Predicate<IExpr> predicate)
        Apply the predicate to each element in this AST and append the elements which satisfy the predicate to the filterAST, or otherwise append it to the restAST.
        Parameters:
        filterAST - the elements satisfy match the predicate
        restAST - the elements which don't match the predicate
        predicate - the predicate which filters each element in the range
        Returns:
        the filterList
      • split

        IAST[] split(Predicate<IExpr> predicate)
        Apply the predicate to each element in this AST and append the elements which satisfy the predicate to the 0th element of the result array, or otherwise append it to the 1st element of the result array.
        Parameters:
        predicate - the predicate which filters each element in the range
        Returns:
        the resulting ASTs in the 0-th and 1-st element of the array
      • split

        IAST[] split(Function<IExpr,IExpr> function)
        Apply the function to each element in this AST and append the result elements for which the function returns non-null elements to the 0th element of the result array, or otherwise append it to the 1st element of the result array.
        Parameters:
        function - the function which filters each element in the range by returning a non-null result.
        Returns:
        the resulting ASTs in the 0-th and 1-st element of the array
      • clone

        IAST clone()
        Returns a shallow copy of this IAST instance (the elements themselves are not copied).
        Returns:
        a clone of this IAST instance.
      • append

        IAST append(IExpr expr)
        Append an expression to this list.
        Returns:
        this after appending the given expression.
      • cloneSet

        IAST cloneSet(int position,            IExpr expr)
        Returns a shallow copy of this IAST instance (the elements themselves are not copied) and set the expr at the given position.
        Returns:
        a clone of this IAST instance.
      • copyHead

        IAST copyHead()
        Create a copy of this IAST, which only contains the head element of the list (i.e. the element with index 0).
      • copyUntil

        IAST copyUntil(int index)
        Create a copy of this IAST, which contains alls elements up to index (exclusive).
      • patternHashCode

        int patternHashCode()
        Calculate a special hash value for pattern matching
        Returns:
      • prepend

        IAST prepend(IExpr expr)
        Prepend an expression to this list.
        Returns:
        this after prepending the given expression.
      • args

        ASTRange args()
        Get the range of elements [1..ast.size()[. These range elements are the arguments of a function (represented as an AST).
        Returns:
      • range

        ASTRange range()
        Get the range of elements [0..ast.size()[ of the AST. This range elements are the head of the function prepended by the arguments of a function.
        Returns:
      • range

        ASTRange range(int start)
        Get the range of elements [start..sizeOfAST[ of the AST
        Returns:
      • range

        ASTRange range(int start,             int end)
        Get the range of elements [start..end[ of the AST
        Returns:
      • getInt

        IInteger getInt(int index)
        Casts an IExpr at position index to an IInteger.
        Parameters:
        index -
        Returns:
        Throws:
        WrongArgumentType - if the cast is not possible
      • getNumber

        INumber getNumber(int index)
        Casts an IExpr at position index to an INumber.
        Parameters:
        index -
        Returns:
        Throws:
        WrongArgumentType - if the cast is not possible
      • getAST

        IAST getAST(int index)
        Casts an IExpr at position index to an IAST.
        Parameters:
        index -
        Returns:
        Throws:
        WrongArgumentType - if the cast is not possible
      • getList

        IAST getList(int index)
        Casts an IExpr which is a list at position index to an IAST.
        Parameters:
        index -
        Returns:
        Throws:
        WrongArgumentType

SCaVis 2.0 © jWork.ORG