Skip to content

Commit

Permalink
refactor(bool fn trait): removed redundant code from table's substitute
Browse files Browse the repository at this point in the history
  • Loading branch information
AurumTheEnd committed May 9, 2024
1 parent 94de92f commit 7a7e704
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/table/traits/boolean_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ impl<T: Debug + Clone + Ord + 'static> BooleanFunction<T> for TruthTable<T> {
);

// alter current valuation based on mappings
for (index, (_bool, variable)) in
original_point.into_iter().zip(&final_inputs).enumerate()
{
for (index, variable) in final_inputs.iter().enumerate() {
if let Some(substitution_table) = mapping.get(variable) {
let output = substitution_table.evaluate(&original_valuation);
final_point[index] = output;
Expand All @@ -122,8 +120,7 @@ impl<T: Debug + Clone + Ord + 'static> BooleanFunction<T> for TruthTable<T> {
.expect(
"Point should be from domain of the same dimension as the number of inputs",
);
let final_index = values_to_row_index(&self.inputs, &final_valuation);
outputs.push(self.outputs[final_index])
outputs.push(self.evaluate(&final_valuation))
}

TruthTable::new(Vec::from_iter(final_inputs), outputs)
Expand Down

0 comments on commit 7a7e704

Please sign in to comment.