Skip to content

Commit

Permalink
Merge pull request #31 from timbeurskens/feature/better-tabular-forma…
Browse files Browse the repository at this point in the history
…tting

use proper markdown tabular format in truth-table output
  • Loading branch information
timbeurskens authored Apr 3, 2022
2 parents 3fae079 + 1af4f50 commit f490346
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rsbdd"
version = "0.7.0"
version = "0.7.1"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
21 changes: 14 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,14 @@ fn main() {
_ => TruthTableEntry::Any,
};

let widths: Vec<usize> = input_parsed
.free_vars
.iter()
.map(|v| max(5, v.len()) as usize)
.collect();
let mut headers = input_parsed.free_vars.clone();
headers.push("*".to_string());

let widths: Vec<usize> = headers.iter().map(|v| max(5, v.len()) as usize).collect();

if args.is_present("show_truth_table") {
print!("|");
for free_var in &input_parsed.free_vars {
for free_var in &headers {
let len = 1 + max(5, free_var.len());
print!(" {:indent$}|", free_var, indent = len);
}
Expand Down Expand Up @@ -271,7 +270,15 @@ fn print_truth_table_recursive(
for (i, var) in vars.iter().enumerate() {
print!(" {:indent$} |", var, indent = sizes[i]);
}
println!(" {:?}", c);
println!(
" {:indent$} |",
match c {
BDD::True => "True",
BDD::False => "False",
_ => unreachable!(),
},
indent = sizes[vars.len()]
);
}
_ => {}
}
Expand Down

0 comments on commit f490346

Please sign in to comment.