kalker/kalk
2020-06-12 00:08:14 +02:00
..
src Extended parser::eval and parser::parse documentation by explaining when None is returned. 2020-06-11 23:45:54 +02:00
Cargo.toml Added readme to Cargo.toml. 2020-06-12 00:08:14 +02:00
README.md Added separate readme for the library. 2020-06-12 00:06:15 +02:00

kalk

Kalk is a math parser library that supports user-defined variables and functions. An example of what it can parse:

f(x, y) = sum(1, 3, (2sin4/x!)^y) + cos(n deg)
a = 3
f(a, 2)

>> 1.1899401098014355

Features

  • Operators: +, -, *, /, !
  • Groups: (), ⌈⌉, ⌋⌊
  • Pre-defined functions and constants
  • User-defined functions and variables. f(x, y) = xy, x = 5
  • Understands fairly ambiguous syntax. Eg. 2sin50 + 2xy

Usage

use kalk::parser;

...
let parser_context = parser::Context::new();
assert_eq!(parser_context.eval("5*3").unwrap().unwrap(), 15);

Compiling

Make sure you have diffutils gcc make and m4 installed.