#![allow(dead_code)]
pub mod integrater;
pub mod plotter;
pub mod utils;

pub fn parse(expression: &str) -> Box<dyn Fn(f64) -> Result<f64, fynsul_core::EvalError>> {
    let ast = fynsul_core::parse!(expression).unwrap(); //TODO: handle error
    fynsul_core::ast_to_func(&ast, "x").unwrap() //TODO: handle error
}

pub fn try_eval(expression: &str, iden: &str, val: f64) -> Result<f64, fynsul_core::Error> {
    let ast = fynsul_core::parse!(expression)?;
    let f = fynsul_core::ast_to_func(&ast, iden)?;
    Ok(f(val)?)
}
