Symbol
org.matheclipse.core.expression

Class Symbol

    • Constructor Detail

      • Symbol

        public Symbol(String symbolName)
    • Method Detail

      • reassignSymbolValue

        public IExpr[] reassignSymbolValue(Function<IExpr,IExpr> function,                          ISymbol functionSymbol)
        Apply the function to the currently assigned value of the symbol and reassign the result value to the symbol.
        Specified by:
        reassignSymbolValue in interface ISymbol
        Parameters:
        function - the function which should be applied
        functionSymbol - TODO
        Returns:
        an array with the currently assigned value of the symbol and the new calculated value of the symbol or null if the reassignment isn't possible.
      • getAssignedValue

        public IExpr getAssignedValue()
        Get the value which is assigned to the symbol or null, if no value is assigned.
        Specified by:
        getAssignedValue in interface ISymbol
        Returns:
        null, if no value is assigned.
      • apply

        public IExpr apply(IExpr... expressions)
        Specified by:
        apply in interface IExpr
        Overrides:
        apply in class ExprImpl
        Returns:
        an IExpr instance with the current expression as head(), and leaves as leaves().
      • pushLocalVariable

        public void pushLocalVariable()
        Create a new variable placeholder on the symbols variable stack
        Specified by:
        pushLocalVariable in interface ISymbol
      • pushLocalVariable

        public void pushLocalVariable(IExpr expression)
        Create a new variable placeholder on the symbols variable stack and set the local value
        Specified by:
        pushLocalVariable in interface ISymbol
      • popLocalVariable

        public void popLocalVariable()
        Delete the topmost placeholder from the local variable stack
        Specified by:
        popLocalVariable in interface ISymbol
      • clear

        public void clear(EvalEngine engine)
        Clear the associated rules for this symbol
        Specified by:
        clear in interface ISymbol
      • clearAll

        public void clearAll(EvalEngine engine)
        Clear all associated rules and attributes for this symbol
        Specified by:
        clearAll in interface ISymbol
      • equals

        public boolean equals(Object obj)
        Test if this is equal to b.
        Specified by:
        equals in interface Element<IExpr>
        Overrides:
        equals in class Object
        Returns:
        true if this is equal to b, else false.
      • isSymbolName

        public boolean isSymbolName(String name)
        Description copied from interface: ISymbol
        Returns true, if this symbol has the given name. The comparison of the symbols name with the given name is done according to the Config.PARSER_USE_LOWERCASE_SYMBOLS setting.
        Specified by:
        isSymbolName in interface ISymbol
      • evaluate

        public IExpr evaluate(EvalEngine engine)
        Evaluate an expression
        Specified by:
        evaluate in interface IExpr
        Overrides:
        evaluate in class ExprImpl
        Parameters:
        engine - the evaluation engine
        Returns:
        the evaluated Object or null if the evaluation is not possible (i.e. the evaluation doesn't change the object).
      • getAttributes

        public final int getAttributes()
        Get the Attributes of this symbol (i.e. LISTABLE, FLAT, ORDERLESS,...)
        Specified by:
        getAttributes in interface ISymbol
        Returns:
        See Also:
        ISymbol.FLAT
      • getEvaluator

        public IEvaluator getEvaluator()
        Get the current evaluator for this symbol
        Specified by:
        getEvaluator in interface ISymbol
        Returns:
        the evaluator which is associated to this symbol or null if no evaluator is associated
      • hasLocalVariableStack

        public boolean hasLocalVariableStack()
        Is a local variable stack created for this symbol ?
        Specified by:
        hasLocalVariableStack in interface ISymbol
        Returns:
        true if this symbol has a local variable stack
      • get

        public IExpr get()
        Get the topmost value from the local variable stack
        Specified by:
        get in interface ISymbol
        Returns:
        null if no local variable is defined
      • set

        public void set(IExpr value)
        Set the value of the local variable on top of the local variable stack
        Specified by:
        set in interface ISymbol
      • hierarchy

        public int hierarchy()
        A unique integer ID for the implementation of this expression
        Specified by:
        hierarchy in interface IExpr
        Returns:
        a unique integer id for the implementation of this expression
      • isString

        public final boolean isString(String str)
        Tests if this symbols name equals the given string
        Specified by:
        isString in interface ISymbol
        Returns:
      • putDownRule

        public IPatternMatcher putDownRule(ISymbol symbol,                          boolean equalRule,                          IExpr leftHandSide,                          IExpr rightHandSide,                          boolean packageMode)
        Associate a new "down value" rule with default priority to this symbol.
        Specified by:
        putDownRule in interface ISymbol
        equalRule - true if the leftHandSide could be matched with equality
        packageMode - TODO
        Returns:
        See Also:
        ISymbol.DEFAULT_RULE_PRIORITY
      • putDownRule

        public IPatternMatcher putDownRule(ISymbol setSymbol,                          boolean equalRule,                          IExpr leftHandSide,                          IExpr rightHandSide,                          int priority,                          boolean packageMode)
        Associate a new rule with the given priority to this symbol.
        Rules with lower numbers have higher priorities.
        Specified by:
        putDownRule in interface ISymbol
        equalRule - true if the leftHandSide could be matched with equality
        priority - the priority of the rule
        packageMode - TODO
        Returns:
        See Also:
        ISymbol.DEFAULT_RULE_PRIORITY
      • putUpRule

        public IPatternMatcher putUpRule(ISymbol setSymbol,                        boolean equalRule,                        IAST leftHandSide,                        IExpr rightHandSide,                        int priority)
        Associate a new "up value" rule with the given priority to this symbol.
        Rules with lower numbers have higher priorities.
        Specified by:
        putUpRule in interface ISymbol
        equalRule - true if the leftHandSide could be matched with equality
        priority - the priority of the rule
        Returns:
        See Also:
        ISymbol.DEFAULT_RULE_PRIORITY
      • setAttributes

        public void setAttributes(int attributes)
        Set the Attributes of this symbol (i.e. LISTABLE, FLAT, ORDERLESS,...)
        Specified by:
        setAttributes in interface ISymbol
        Parameters:
        attributes - the Attributes of this symbol
      • setEvaluator

        public final void setEvaluator(IEvaluator evaluator)
        Set the current evaluator which is associated to this symbol
        Specified by:
        setEvaluator in interface ISymbol
      • compareTo

        public int compareTo(IExpr obj)
        Compares this expression with the specified expression for order. Returns a negative integer, zero, or a positive integer as this expression is canonical less than, equal to, or greater than the specified expression.
        Specified by:
        compareTo in interface Element<IExpr>
        Specified by:
        compareTo in interface Comparable<IExpr>
        Specified by:
        compareTo in interface IExpr
        Returns:
        0 if this is equal to b, -1 if this is less then b, else +1.
      • isAtom

        public final boolean isAtom()
        Test if this expression is an atomic expression (i.e. no AST expression)
        Specified by:
        isAtom in interface IExpr
        Overrides:
        isAtom in class ExprImpl
      • isTrue

        public boolean isTrue()
        Test if this expression equals the symbol "True"
        Specified by:
        isTrue in interface IExpr
        Overrides:
        isTrue in class ExprImpl
      • isValue

        public final boolean isValue()
        Returns true, if this symbol or ast expression is bound to a value (i.e. the evaluation returns an assigned value).
        Specified by:
        isValue in interface IExpr
        Overrides:
        isValue in class ExprImpl
      • isFalse

        public boolean isFalse()
        Test if this expression equals the symbol "False"
        Specified by:
        isFalse in interface IExpr
        Overrides:
        isFalse in class ExprImpl
      • isNegative

        public boolean isNegative()
        Test if this object is a negative signed number.
        Specified by:
        isNegative in interface IExpr
        Overrides:
        isNegative in class ExprImpl
        Returns:
        true, if this < 0; false in all other case.
      • isPositive

        public boolean isPositive()
        Test if this object is a positive signed number.
        Specified by:
        isPositive in interface IExpr
        Overrides:
        isPositive in class ExprImpl
        Returns:
        true, if this > 0; false in all other case.
      • head

        public ISymbol head()
        If this object is an instance of IAST get the first element (offset 0) of the IAST list (i.e. get(0) ).
        Specified by:
        head in interface IExpr
        Specified by:
        head in class ExprImpl
        Returns:
        the head of the expression, which must not be null.
      • getSymbol

        public final String getSymbol()
      • variables2Slots

        public IExpr variables2Slots(Map<IExpr,IExpr> map,                    List<IExpr> variableList)
        Description copied from interface: IExpr
        Convert the variables (i.e. ISymbol's with lower case character in the 0-th position of their name) in this expression into Slot[] s.
        Specified by:
        variables2Slots in interface IExpr
        Overrides:
        variables2Slots in class ExprImpl
        Returns:
        null if the expression contains a variable with a '$' character in the 0-th position of its name and the math engine runs in server mode.
      • internalFormString

        public String internalFormString(boolean symbolsAsFactoryMethod,                        int depth)
        Description copied from interface: IExpr
        Return the internal Java form of this expression.
        Specified by:
        internalFormString in interface IExpr
        Overrides:
        internalFormString in class ExprImpl
        Parameters:
        symbolsAsFactoryMethod - if true use the F.symbol() method, otherwise print the symbol name.
        depth - the recursion depth of this call. 0 indicates "recurse without a limit".
      • definition

        public List<IAST> definition()
        Return a list of the rules associated to this symbol
        Specified by:
        definition in interface ISymbol
        Returns:
      • getDefaultValue

        public IExpr getDefaultValue()
        Get the general default value for this symbol (i.e. 1 is the default value for Times, 0 is the default value for Plus). The general default value is used in pattern-matching for expressions like a_. * b_. + c_
        Specified by:
        getDefaultValue in interface ISymbol
        Returns:
        the default value or null if undefined.
      • getDefaultValue

        public IExpr getDefaultValue(int pos)
        Get the default value at the arguments position for this symbol (i.e. 1 is the default value for Power at position 2). The default value is used in pattern-matching for expressions like a ^ b_.
        Specified by:
        getDefaultValue in interface ISymbol
        Parameters:
        pos - the position for the default value
        Returns:
        the default value or null if undefined.
      • setDefaultValue

        public void setDefaultValue(IExpr expr)
        Set the general default value for this symbol (i.e. 1 is the default value for Times, 0 is the default value for Plus). The general default value is used in pattern-matching for expressions like a_. * b_. + c_
        Specified by:
        setDefaultValue in interface ISymbol
        Parameters:
        expr - the general default value
        See Also:
        ISymbol.getDefaultValue()
      • setDefaultValue

        public void setDefaultValue(int pos,                   IExpr expr)
        Set the default value at the arguments position for this symbol (i.e. 1 is the default value for Power at position 2). The default value is used in pattern-matching for expressions like a ^ b_.
        Specified by:
        setDefaultValue in interface ISymbol
        Parameters:
        pos - the position for the default value
        expr - the default value for the given position
        See Also:
        ISymbol.getDefaultValue(int)
      • accept

        public <T> T accept(IVisitor<T> visitor)
        Accept a visitor with return type T
        Specified by:
        accept in interface IExpr
      • accept

        public boolean accept(IVisitorBoolean visitor)
        Accept a visitor with return type boolean
        Specified by:
        accept in interface IExpr
      • accept

        public int accept(IVisitorInt visitor)
        Accept a visitor with return type int
        Specified by:
        accept in interface IExpr
        Returns:
      • mapConstantDouble

        public IExpr mapConstantDouble(INumericFunction<IExpr> function)
        If this symbol has attribute ISymbol.CONSTANT and the symbol's evaluator is of instance INumericConstant, then apply the constants double value to the given function and return the result, otherwise return null.
        Specified by:
        mapConstantDouble in interface ISymbol
        Parameters:
        function - applys the function to a double value, resulting in an object of type IExpr.
        Returns:
        the resulting expression from the function or null.
        See Also:
        Abs, Ceiling, Floor

SCaVis 1.8 © jWork.org