Pattern matching - axkr/symja_android_library GitHub Wiki
How to use pattern-matching
Overview
If you want to manipulate IExpr
objects in Symja the dedicated design pattern is the visitor.
The visitor pattern is implemented in this package:
To simplify the manipulation of IExpr
objects a pattern matching mechanism has been designed in the Matcher
and Tester classes.
import static org.matheclipse.core.expression.F.*;
import org.matheclipse.core.patternmatching.Matcher;
Matcher matcher = new Matcher();
matcher.caseOf(Sin(x_), D(Sin(x), x));
// print Cos(y)
System.out.println(matcher.apply(Sin(y)));