Combuter Algebra System focusing on symbolic transformations.
100% writen in typescript.
Parser generated using ANTLR4.
Note: Algebrain is still at a very early and unstable stage.
$ npm install algebrain
;const expr = Algebrain;// Your string expression is now a tree of nodes:// +// ├── *// │ ├── 1.6// │ └── ^// │ ├── 3// │ └── 2// └── /// ├── 5// └── -// ├── y// └── 12.34const evaluated = expr;// Evaluated tree of the following form:// +// ├── 14.4// └── /// ├── 5// └── -// ├── y// └── 12.34console;// > My evaluated expression is: 14.4+5/(y-12.34)
Under the hood, the above parsing uses an extensive API for structuring algebraic expressions:
// Algebrain heavily relies on the immutable package for persistent data structures;;// The above expression: 14.4+5/(y-12.34), is constructed as:const expr = OperatorSymbolPlus;console;// > 14.4+5/(y-12.34)
By exploiting the concept of rewriting rules, Algebrain enables the use of custom transformations, that can be entirely developed and compiled within its environment.
;const rules =AlgebrainAlgebrainAlgebrain;const fibonacci = "fib" rules;const expr = Algebrain;console;// > The 15h term of fibonacci is 610
Interpreter - The execution framework of Algebrain
Similar to any traditional Computer Algebra System, Algebrain provides a progamming language and an intepreter.
Every Algebrain statement or expression, when parsed, results to an object implementing the
✍️ more documentation to come...
There is a web-app client that materiliases a friendly interface for exploring algebrain at https://algebrain.io
The source repo of the React app can be found here.
# Lintingnpm run lint# Unit tests w/ coverage thresholdsnpm run test# Compile typescriptnpm run build# Please commit through the following npm scriptsnpm run precommitnpm run commit