To implement Mathematica style pattern matching