fix: truth table reversed output
This commit is contained in:
parent
b8c12047a5
commit
b01b184e46
|
@ -6,6 +6,7 @@ mod truth_table;
|
||||||
mod ast;
|
mod ast;
|
||||||
|
|
||||||
use gray_code::gray_code;
|
use gray_code::gray_code;
|
||||||
|
use truth_table::print_truth_table;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello, world!");
|
println!("Hello, world!");
|
||||||
|
@ -18,4 +19,5 @@ fn main() {
|
||||||
println!("{}", gray_code(15));
|
println!("{}", gray_code(15));
|
||||||
println!("{}", gray_code(7));
|
println!("{}", gray_code(7));
|
||||||
println!("{}", gray_code(3));
|
println!("{}", gray_code(3));
|
||||||
|
print_truth_table("ZFG|&");
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ fn recursive_fn(formula: &str, mut vec: Vec<char>, format: String) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_truth_table(formula: &str) {
|
pub fn print_truth_table(formula: &str) {
|
||||||
let set: HashSet<char> = get_hashset(formula);
|
let set: HashSet<char> = get_hashset(formula);
|
||||||
let mut vec: Vec<char> = set.iter().cloned().collect();
|
let mut vec: Vec<char> = set.iter().cloned().collect();
|
||||||
vec.sort();
|
vec.sort();
|
||||||
|
@ -87,6 +87,6 @@ fn print_truth_table(formula: &str) {
|
||||||
separator = format!("{separator}---|");
|
separator = format!("{separator}---|");
|
||||||
println!("{format}");
|
println!("{format}");
|
||||||
println!("{separator}");
|
println!("{separator}");
|
||||||
recursive_fn(formula, vec, String::from("|"));
|
recursive_fn(formula, vec.into_iter().rev().collect(), String::from("|"));
|
||||||
// call eval formula a lot
|
// call eval formula a lot
|
||||||
}
|
}
|
Loading…
Reference in New Issue