fix(lib|main): fix format
This commit is contained in:
parent
693ff1c496
commit
5b64cddc01
11
src/lib.rs
11
src/lib.rs
|
@ -8,14 +8,17 @@ pub mod parser;
|
|||
pub mod maths;
|
||||
|
||||
|
||||
pub fn format(v: &Vec<GaussianRational>) -> String {
|
||||
pub fn format(v: &[GaussianRational]) -> String {
|
||||
let mut format;
|
||||
format = v[0].format(false);
|
||||
if v.len() > 1 {
|
||||
let mut format2 = v[1].format(true);
|
||||
if format2 == "" {
|
||||
if format == "" {
|
||||
format = format!("{}x", v[1].format(true));
|
||||
format = format!("{}x", format2);
|
||||
} else {
|
||||
format = format!("{format} + {}x", v[1].format(true));
|
||||
format = format!("{format} + {}x", format2);
|
||||
}
|
||||
}
|
||||
}
|
||||
for i in 2..v.len() {
|
||||
|
@ -41,7 +44,7 @@ pub fn parse(query: &str) -> Result<Node, Box<dyn Error>> {
|
|||
Ok(ast)
|
||||
}
|
||||
|
||||
fn print_reduced_form(equation: &Vec<f64>) {
|
||||
fn print_reduced_form(equation: &[f64]) {
|
||||
let mut string = String::from("Reduced form: ");
|
||||
|
||||
for (i, n) in equation.iter().enumerate() {
|
||||
|
|
|
@ -17,7 +17,11 @@ fn main() {
|
|||
process::exit(1);
|
||||
});
|
||||
if is_equation {
|
||||
println!("{} = 0", computorv1::format(&evaluated));
|
||||
let mut format = computorv1::format(&evaluated);
|
||||
if format == "" {
|
||||
format = String::from("0");
|
||||
}
|
||||
println!("{} = 0", format);
|
||||
computorv1::maths::solver::solve(evaluated);
|
||||
} else {
|
||||
println!("{} is equal to:", args[1]);
|
||||
|
|
Loading…
Reference in New Issue