Pattern match returns false, while it should return true

Issue #150 resolved
Former user created an issue

Hi, I use the next code, the test method should return true, but it returns false.

ExprEvaluator util = new ExprEvaluator();
IExpr pattern = util.evaluate("c_+a_+b_==d_");
IExpr exp = util.evaluate("x-y+o==t");
IPatternMatcher matcher = new PatternMatcher(pattern);
boolean test = matcher.test(exp);

Comments (4)

  1. Axel Kramer repo owner

    this example created with the latest GIT sources gives "true" in my dev environment?

    package org.matheclipse.core.examples;
    
    import org.matheclipse.core.eval.ExprEvaluator;
    import org.matheclipse.core.interfaces.IExpr;
    import org.matheclipse.core.patternmatching.IPatternMatcher;
    import org.matheclipse.core.patternmatching.PatternMatcher;
    import org.matheclipse.parser.client.SyntaxError;
    import org.matheclipse.parser.client.math.MathException;
    
    public class PatternMatchingExample {
        public static void main(String[] args) {
            try {
                ExprEvaluator util = new ExprEvaluator();
                IExpr pattern = util.evaluate("c_+a_+b_==d_");
                IExpr exp = util.evaluate("x-y+o==t");
                IPatternMatcher matcher = new PatternMatcher(pattern);
                boolean test = matcher.test(exp);
                System.out.println(test);
            } catch (SyntaxError e) {
                // catch Symja parser errors here
                System.out.println(e.getMessage());
            } catch (MathException me) {
                // catch Symja math errors here
                System.out.println(me.getMessage());
            } catch (final Exception ex) {
                System.out.println(ex.getMessage());
            } catch (final StackOverflowError soe) {
                System.out.println(soe.getMessage());
            } catch (final OutOfMemoryError oome) {
                System.out.println(oome.getMessage());
            }
        }
    }
    
  2. Log in to comment