No description
Find a file
2019-05-20 00:56:37 -04:00
examples variable-less expressions 2018-11-05 19:42:33 -05:00
algebra.nim Removed deprecated .isAlphaAscii(); changed templates to overloaded procs 2019-05-20 00:56:37 -04:00
algebra.nimble Removed deprecated .isAlphaAscii(); changed templates to overloaded procs 2019-05-20 00:56:37 -04:00
LICENSE . 2018-10-28 17:15:38 -04:00
README.md readme 2018-11-05 19:56:42 -05:00

Algebra Parser & Evaluator

Example

import algebra

echo evaluate(expr"1.5+1.5")
#=> 3.0

echo evaluate(expr"a/ln(b)", {"a": 5.5, "b": 2.2})
#=> 6.975646720399666

echo evaluate(expr"sin(a)", "a", [0.0, 1.0, 2.0, 3.0, 4.0, 4.5])
#=> @[0.0, 0.8414709848078965, 0.9092974268256817, 0.1411200080598672, -0.7568024953079282, -0.977530117665097]

Parsing Details

  • After a function name (e.g. sin, cos, ln, etc.), a left parenthesis (() must always immediately follow.
  • The expr procedure returns the tokens after the Shunting-Yard algorithm is applied.