Solutions approach
We will divide the requirement into the two following parts:
- A library for evaluating arbitrary mathematical expressions
- An application which will consume the aforementioned library to plot data
The expression evaluator library requirements can be enumerated as follows:
- Modeling expressions as AST
- Writing a lexical analyzer
- Writing a recursive descent parser
- Depth first walk of the tree
- Supporting trigonometric functions and pseudo variable (
$
) - Packaging everything as a facade pattern-based API
The application requirements can be enumerated as follows:
- A screen with a WPF 2D graphics surface
- A prompt for entering expressions
- Implementation of the observer for detecting a new plot request
- Passing the value to the expressions library for change in the X-coordinate value
- Rendering the resulting value