//! Printer troubleshooter example from Wikipedia //! //! https://en.wikipedia.org/wiki/Decision_table#Example use decision_table::{DecisionTable, Domain, Row}; fn print_completeness(table: &DecisionTable) { if table.is_complete() { println!("Complete!"); } else { println!("Incomplete!"); } } fn main() { let boolean_domain = Domain::from(vec!["no", "yes"]); let mut table = DecisionTable::new(vec![&boolean_domain, &boolean_domain, &boolean_domain]); table.add(Row::new(vec!["no", "yes", "no"], "01110")); table.add(Row::new(vec!["no", "yes", "yes"], "00011")); table.add(Row::new(vec!["no", "no", "no"], "11100")); table.add(Row::new(vec!["no", "no", "yes"], "00001")); table.add(Row::new(vec!["yes", "yes", "no"], "00100")); table.add(Row::new(vec!["yes", "yes", "yes"], "00010")); table.add(Row::new(vec!["yes", "no", "no"], "00100")); table.add(Row::new(vec!["yes", "no", "yes"], "00000")); // Complete! print_completeness(&table); table.remove(&Row::new(vec!["yes", "no", "yes"], "00000")); // Incomplete! print_completeness(&table); }