kalker/kalk
2020-12-28 19:13:39 +01:00
..
src Fixed function declarations not being parsed 2020-12-28 19:13:39 +01:00
Cargo.toml v0.3.8 2020-12-14 00:07:19 +01:00
README.md Updated example code in README. 2020-06-12 21:00:03 +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
  • Syntax highlighting
  • Special-symbol completion on tab. Eg. write sqrt and press tab. It will be turned into .

Usage

use kalk::parser;
let mut parser_context = parser::Context::new();
let precision = 53;
assert_eq!(parser::eval(&mut parser_context, "5*3", precision).unwrap().unwrap(), 15);

Compiling

Make sure you have diffutils gcc make and m4 installed.