https://github.com/entonio/expressive
Model, solve, and simplify mathematical expressions
https://github.com/entonio/expressive
expression expression-builder expression-evaluator expression-parser expression-solver
Last synced: 11 months ago
JSON representation
Model, solve, and simplify mathematical expressions
- Host: GitHub
- URL: https://github.com/entonio/expressive
- Owner: entonio
- License: apache-2.0
- Created: 2024-04-11T01:54:48.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-03T02:45:42.000Z (over 1 year ago)
- Last Synced: 2025-02-19T13:48:08.277Z (11 months ago)
- Topics: expression, expression-builder, expression-evaluator, expression-parser, expression-solver
- Language: Swift
- Homepage:
- Size: 49.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Expressive
==========
The purpose of this package is to model mathematical expressions.
Expressions can be entirely numerical or they may contain variables, represented by strings of letters.
This being Swift, expressions may be written using number and string literals connected using the normal mathematical operators, or they can be parsed from strings, or mixing the two approaches.
The numerical value of expressions can be calculated by providing a map of values for the variables, if there are any. Values can be numerical, or other expressions.
This enables a program to treat mathematical formulae as data that can be passed around, read dynamically, or combined.
Expressions can be simplified. This is not an objective transformation, so the result may or may not suit your intent.
Expressions can provide a notationally correct description of their contents.
Goals of this package:
- expressiveness
- ease of use
- correctness
Not goals:
- performance
- completeness of mathematical API
Examples
========
```swift
let VIG: Expression = "VIG"
let NEX: Expression = "NEX"
let E1 = 16 + VIG + (3 + VIG) * (NEX - 5) / 5
let E2 = "16+VIG+(3+VIG)*(NEX-5)/5" as Expression
let E3 = "16 + VIG" as Expression + "(3 + VIG) * (NEX - 5) / 5"
XCTAssertEqual(E1, E2)
XCTAssertEqual(E1, E3)
```
License
-------
Except where/if otherwise specified, all the files in this package are copyright of the package contributors mentioned in the `NOTICE` file and licensed under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0), which is permissive for business use.