org.matheclipse.core.patternmatching
Class PatternMatcher
- java.lang.Object
-
- org.matheclipse.core.patternmatching.IPatternMatcher
-
- org.matheclipse.core.patternmatching.PatternMatcher
-
- Direct Known Subclasses:
- PatternMatcherAndEvaluator, PatternMatcherAndInvoker
public class PatternMatcher extends IPatternMatcher implements java.io.Serializable
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description classPatternMatcher.OrderlessMatcherMatches anIASTwith header attributeOrderless.
-
Constructor Summary
Constructors Constructor and Description PatternMatcher()Needed for serializationPatternMatcher(IExpr patternExpr)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleanapply(IExpr leftHandSide)Start pattern matching.booleancheckCondition()Check if the condition for this pattern matcher evaluates totrue.booleancheckRHSCondition(EvalEngine engine)Check if the condition for the right-hand-sidesModule[] or Condition[]expressions evaluates totrue.java.lang.Objectclone()booleanequals(java.lang.Object obj)Indicates whether another object is equal to this predicate.static booleanequivalent(IExpr patternExpr1, IExpr patternExpr2)Check if the two left-hand-side pattern expressions are equivalent.IExpreval(IExpr leftHandSide)Match the given left-hand-side and return an evaluated expressionstatic IExprevalLeftHandSide(IAST leftHandSide)static IExprevalLeftHandSide(IAST leftHandSide, EvalEngine engine)Transform the ast recursively, according to the attributes Flat, HoldAll, HoldFirst, HoldRest, Orderless for the left-hand-side of a Set[] or SetDelayed[] expression.IExprgetCondition()Get the additional condition for pattern-matchingvoidgetPatterns(java.util.List<IExpr> resultList, IExpr pExpr)Returns the matched pattern in the order they appear in the pExprinthashCode()booleanisRuleWithoutPatterns()Returns true if the given expression contains no patternsvoidsetCondition(IExpr condition)Sets an additional evaluation-condition for pattern-matching-
Methods inherited from class org.matheclipse.core.patternmatching.IPatternMatcher
getLHS, getRHS
-
-
-
-
Constructor Detail
-
PatternMatcher
public PatternMatcher()
Needed for serialization- Parameters:
patternExpr-
-
PatternMatcher
public PatternMatcher(IExpr patternExpr)
-
-
Method Detail
-
checkRHSCondition
public boolean checkRHSCondition(EvalEngine engine)
Check if the condition for the right-hand-sidesModule[] or Condition[]expressions evaluates totrue. Override it in subclasses.- Returns:
true- See Also:
PatternMatcherAndEvaluator.checkRHSCondition(EvalEngine)
-
checkCondition
public boolean checkCondition()
Check if the condition for this pattern matcher evaluates totrue.
-
equivalent
public static boolean equivalent(IExpr patternExpr1, IExpr patternExpr2)
Check if the two left-hand-side pattern expressions are equivalent. (i.e.f[x_,y_]is equivalent tof[a_,b_])- Parameters:
patternExpr1-patternExpr2-pm1-pm2-- Returns:
-
getPatterns
public void getPatterns(java.util.List<IExpr> resultList, IExpr pExpr)
Returns the matched pattern in the order they appear in the pExpr- Specified by:
getPatternsin classIPatternMatcher- Parameters:
resultList-pExpr-
-
isRuleWithoutPatterns
public final boolean isRuleWithoutPatterns()
Returns true if the given expression contains no patterns- Specified by:
isRuleWithoutPatternsin classIPatternMatcher- Returns:
-
apply
public boolean apply(IExpr leftHandSide)
Description copied from class:IPatternMatcherStart pattern matching.- Specified by:
applyin interfacePredicate<IExpr>- Specified by:
applyin classIPatternMatcher- Returns:
trueif theexprmatches the pattern-matchings left-hand-side expression.
-
eval
public IExpr eval(IExpr leftHandSide)
Description copied from class:IPatternMatcherMatch the given left-hand-side and return an evaluated expression- Specified by:
evalin classIPatternMatcher- Returns:
nullif the match wasn't successful, the evaluated expression otherwise.
-
equals
public boolean equals(java.lang.Object obj)
Description copied from interface:PredicateIndicates whether another object is equal to this predicate.Most implementations will have no reason to override the behavior of
Object.equals(java.lang.Object). However, an implementation may also choose to returntruewheneverobjectis aPredicatethat it considers interchangeable with this one. "Interchangeable" typically means thatthis.apply(t) == that.apply(t)for alltof typeT). Note that afalseresult from this method does not imply that the predicates are known not to be interchangeable.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException- Overrides:
clonein classIPatternMatcher- Throws:
java.lang.CloneNotSupportedException
-
getCondition
public IExpr getCondition()
Get the additional condition for pattern-matching
-
setCondition
public void setCondition(IExpr condition)
Sets an additional evaluation-condition for pattern-matching
-
evalLeftHandSide
public static IExpr evalLeftHandSide(IAST leftHandSide, EvalEngine engine)
Transform the ast recursively, according to the attributes Flat, HoldAll, HoldFirst, HoldRest, Orderless for the left-hand-side of a Set[] or SetDelayed[] expression. Delegates toEvalEngine#evalSetAttributes()method- Parameters:
ast-- Returns:
- See Also:
org.matheclipse.core.eval.EvalEngine#evalSetAttributes()
-
-
DMelt 3.0 © DataMelt by jWork.ORG