The library looks great so far!
Do you think it would be possible to add a function to bind several variables?
Something like the following:
pub fn bind_multiple<'a>(self, vars: &[&str])
It would be also helpful if we could evaluate the expression by providing a Map of variables tied with their values.
let expr = meval::Expr::from_str("sin(pi * x + y)").unwrap();
let mut map: HashMap<String, f64> = HashMap::new();
map.insert("x".to_owned(), 42f64);
map.insert("y".to_owned(), 24f64);
let r = expr.eval(map).unwrap();
Or maybe it could be done this way:
let mut expr = meval::Expr::from_str("sin(pi * x + y)").unwrap();
expr = expr.bind("x", 42f64).unwrap();
expr = expr.bind("y", 24f64).unwrap();
let r = expr.eval().unwrap();
The library looks great so far! Do you think it would be possible to add a function to bind several variables?
Something like the following:
It would be also helpful if we could evaluate the expression by providing a
Map
of variables tied with their values.Or maybe it could be done this way: