2个版本
0.0.2 | 2019年3月19日 |
---|---|
0.0.1 | 2019年3月19日 |
#820 in 数学
22KB
572 代码行
mathew

带有上下文和浮点方法的数学表达式求值器
use mathew::Eval;
fn main() -> Result<(), ()> {
let e = Eval::default().insert("foo", "1")?.insert("bar", "0")?;
assert_eq!(e.eval("foo + bar").unwrap(), 1.0);
assert_eq!(e.eval("foo - bar * 1").unwrap(), 1.0);
assert_eq!(e.eval("1 + bar").unwrap(), 1.0);
assert_eq!(e.eval("2.5.powi(2 * foo)").unwrap(), 6.25);
Ok(())
}
贡献
请为mathew做出贡献!越多越好!请随时提出问题或直接与所有者联系以提出任何请求或建议。
行为准则
本行为准则借鉴自贡献者公约,版本1.4,可在http://contributor-covenant.org/version/1/4找到
许可证
本项目根据Apache许可证(版本2.0)和MIT许可证的条款分发,分别可在LICENSE-APACHE和LICENSE-MIT中找到。
支持
依赖项
~2MB
~46K SLoC