-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Open
Labels
EnhancementPri: 1help wantedIssues identified as good community contribution opportunitiesIssues identified as good community contribution opportunitiesneeds spec
Description
Problem Statement
Currently, Calculator executes all operations in immediate mode--press an operator, get a new answer. For multiple scenarios, it would be useful for the user to enter an expression like "(5 + 2) * 3" and have Calculator parse and compute the result.
Evidence or User Insights
Several proposed features could leverage this work:
- Expression paste Use LR parser to parse expressions coming from the Clipboard and generate commands #344 (includes some prototype code which could be useful for this effort)
- History editing Bring back history editing #163
- Input via ink or voice Add inking support to calculator for basic calculations/conversions or other math needs #24, Use voice input in calculator #288
- Editing expressions in scientific calculator Scientific mode should more scientific #520
Proposal
Add code and tests to the calc engine to parse mathematical expressions as strings.
Goals
- A developer can use the CalcManager library to convert an expression into a numerical result
- Expressions support order of operations, e.g. "(5 + 2) * 3" = 21
- Expressions support evaluation of functions, e.g. "sqrt(4)"
- Functions are implemented for as many existing calculator operators as possible
- Each function has a thoughtful name informed by similar systems
- Expressions are evaluated using the arbitrary-precision engine
- When invalid expressions are passed to the engine, error information is returned which could be used to construct a helpful error message
- Parsing and evaluation is deterministic, and ideally not locale-dependent
- The parser can find expressions embedded in natural language sentences with loose syntax (e.g. "what is the square root of sin(3 - 2)" evaluates to "what is the square root of [expression tree]"), for future use in voice input scenarios
Non-Goals
- Integrate expression parsing with the Calculator UI (tracked by other issues)
- Natural language intent recognition, e.g. "what is the square root of 4" evaluating to "sqrt(4)"
Requested Assignment
I'm happy to help with this, but would be great for someone else to implement.
grochocki, SavoySchuler, Northurland, SaprativRay, prakharb5 and 9 moreTimLovellSmith and SevastiennJay-o-Way
Metadata
Metadata
Assignees
Labels
EnhancementPri: 1help wantedIssues identified as good community contribution opportunitiesIssues identified as good community contribution opportunitiesneeds spec