feat(maths::evaluator): prep evaluator
This commit is contained in:
parent
5fdc0a1231
commit
f9833263ef
|
@ -7,6 +7,11 @@ fn main() {
|
|||
println!("Error during parsing: {e}");
|
||||
process::exit(1);
|
||||
});
|
||||
println!("{:?}", equation);
|
||||
let is_equation = computorv1::maths::evaluator::is_equation(&equation);
|
||||
let evaluated = computorv1::maths::evaluator::evaluate(equation);
|
||||
computorv1::pretty(evaluated);
|
||||
if is_equation {
|
||||
computorv1::maths::solver::solve(evaluated);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use std::ops;
|
||||
|
||||
pub mod evaluator;
|
||||
pub mod solver;
|
||||
|
||||
//TODO slow ? check Stein's algorithm (binaryGCD)
|
||||
fn gcd(a: i128, b: i128) -> i128 {
|
||||
|
|
|
@ -147,3 +147,10 @@ pub fn evaluate(ast: Node) -> Vec<GaussianRational> {
|
|||
Node::Leaf(value) => value,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_equation(ast: &Node) -> bool {
|
||||
match ast {
|
||||
Node::Binary { operator, lhs: _, rhs: _ } => *operator == Token::Equal(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
use super::*;
|
||||
|
||||
pub fn solve(equation: Vec<GaussianRational>) -> Vec<GaussianRational> {
|
||||
vec![]
|
||||
}
|
Loading…
Reference in New Issue