/** * */ public static IPattern valueOf(final ISymbol symbol, final IExpr check, final boolean def) { return new Pattern(symbol, check, def); // p.fSymbol = symbol; // p.fCondition = check; // p.fDefault = def; // return p; }
private Object writeReplace() throws ObjectStreamException { return optional(F.GLOBAL_IDS_MAP.get(this)); } }
@Override public int[] addPattern(PatternMap patternMap, List<IExpr> patternIndexMap) { patternMap.addPattern(patternIndexMap, this); int[] result = new int[2]; if (isPatternDefault() || isPatternOptional()) { // the ast contains a pattern with default value (i.e. "x_." or // "x_:") result[0] = IAST.CONTAINS_DEFAULT_PATTERN; result[1] = 3; } else { // the ast contains a pattern without default value (i.e. "x_") result[0] = IAST.CONTAINS_PATTERN; result[1] = 6; } if (fHeadTest != null) { result[1] += 2; } return result; }
/** * Check if the two left-hand-side pattern expressions are equivalent. (i.e. <code>f[x_,y_]</code> is equivalent to * <code>f[a_,b_]</code> ) * * @param patternObject * @param pm1 * @param pm2 * @return */ @Override public boolean equivalent(final IPatternObject patternObject, final PatternMap pm1, PatternMap pm2) { if (this == patternObject) { return true; } if (patternObject instanceof Pattern) { // test if the pattern indices are equal final IPattern p2 = (IPattern) patternObject; if (getIndex(pm1) != p2.getIndex(pm2)) { return false; } // test if the "check" expressions are equal final IExpr o1 = getHeadTest(); final IExpr o2 = p2.getHeadTest(); if ((o1 == null) || (o2 == null)) { return o1 == o2; } return o1.equals(o2); } return false; }
@Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj instanceof Pattern) { if (hashCode() != obj.hashCode()) { return false; } Pattern pattern = (Pattern) obj; if (fDefault != pattern.fDefault) { return false; } if (fSymbol.equals(pattern.fSymbol)) { return super.equals(obj); } } return false; }
/** {@inheritDoc} */ @Override public boolean matchPattern(final IExpr expr, PatternMap patternMap) { if (!isConditionMatched(expr, patternMap)) { return false; } IExpr value = patternMap.getValue(this); if (value != null) { return expr.equals(value); } patternMap.setValue(this, expr); return true; }
return (hierarchy() - (obj).hierarchy());
/** * Create a pattern for pattern-matching and term rewriting * * @param symbol * @param check * additional condition which should be checked in pattern-matching * @return IPattern */ public static IPattern $p(final ISymbol symbol, final IExpr check) { return org.matheclipse.core.expression.Pattern.valueOf(symbol, check); }
/** * * @param numerator * @return */ public static IPattern valueOf(final ISymbol symbol, final IExpr check) { return new Pattern(symbol, check); // p.fSymbol = symbol; // p.fCondition = check; // return p; }
/** * Create a pattern for pattern-matching and term rewriting * * @param symbol * @return IPattern */ public static IPattern pattern(final ISymbol symbol) { return org.matheclipse.core.expression.Pattern.valueOf(symbol); }
/** * */ public static IPattern valueOf(@Nonnull final ISymbol symbol, final IExpr check, final boolean def) { return new Pattern(symbol, check, def); }
/** * Create a pattern for pattern-matching and term rewriting * * @param symbol * @param check * additional condition which should be checked in pattern-matching * @param def * if <code>true</code>, the pattern can match to a default value associated with the AST's head the * pattern is used in. * @return IPattern */ public static IPattern pattern(final ISymbol symbol, final IExpr check, final boolean def) { return org.matheclipse.core.expression.Pattern.valueOf(symbol, check, def); }
/** * * @param numerator * @return */ public static IPattern valueOf(@Nonnull final ISymbol symbol, final IExpr check) { return new Pattern(symbol, check); }
/** * Create a pattern for pattern-matching and term rewriting * * @param symbol * @param check * additional condition which should be checked in pattern-matching * @return IPattern */ public static IPattern $p(final ISymbol symbol, final IExpr check) { if (symbol == null) { return Pattern.valueOf(null, check); } return Pattern.valueOf((Symbol) symbol, check); }
public static IPattern valueOf(final ISymbol symbol) { if (symbol == null) { return NULL_PATTERN; } IPattern value = F.PREDEFINED_PATTERN_MAP.get(symbol.toString()); if (value != null) { return value; } return new Pattern(symbol); }
/** * Create a pattern for pattern-matching and term rewriting * * @param symbol * @param check * additional condition which should be checked in pattern-matching * @param def * if <code>true</code>, the pattern can match to a default value associated with the AST's head the * pattern is used in. * @return IPattern */ public static IPattern $p(final ISymbol symbol, final IExpr check, final boolean def) { return org.matheclipse.core.expression.Pattern.valueOf(symbol, check, def); }
public static IPattern initPredefinedPattern(@Nonnull final ISymbol symbol) { IPattern temp = new Pattern(symbol); PREDEFINED_PATTERN_MAP.put(symbol.toString(), temp); return temp; }
/** * Create a pattern for pattern-matching and term rewriting * * @param symbol * @param check * additional condition which should be checked in pattern-matching * @param def * if <code>true</code>, the pattern can match to a default value * associated with the AST's head the pattern is used in. * @return IPattern */ public static IPattern $p(final ISymbol symbol, final IExpr check, final boolean def) { if (symbol == null) { return Pattern.valueOf(null, check, def); } return Pattern.valueOf((Symbol) symbol, check, def); }
public static IPattern valueOf(@Nonnull final ISymbol symbol) { if (symbol.getContext().equals(Context.DUMMY)) { IPattern value = F.PREDEFINED_PATTERN_MAP.get(symbol.toString()); if (value != null) { return value; } } return new Pattern(symbol); }