From e9a083baf53ecbf74a7d31cef10955c9e96695f3 Mon Sep 17 00:00:00 2001 From: inthar-raven Date: Mon, 12 Aug 2024 17:47:10 -0400 Subject: [PATCH] chirality should use booth --- src/equal.rs | 14 +++++++------- src/words.rs | 17 +++++------------ 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/equal.rs b/src/equal.rs index bcb3741a..c8470ab2 100644 --- a/src/equal.rs +++ b/src/equal.rs @@ -93,14 +93,14 @@ pub fn ed_tunings_for_ternary( (3..ed_bound) .flat_map(|l| (2..l).flat_map(move |m| (1..m).map(move |s| vec![l, m, s]))) .filter(|edostep_counts| { - let ed: i32 = - edostep_counts[0] * step_sig[0] as i32 - + edostep_counts[1] * step_sig[1] as i32 - + edostep_counts[2] * step_sig[2] as i32; + let ed: i32 = edostep_counts[0] * step_sig[0] as i32 + + edostep_counts[1] * step_sig[1] as i32 + + edostep_counts[2] * step_sig[2] as i32; let aber_size = steps_as_cents(edostep_counts[2], ed as f64, equave); - edostep_counts[0] * step_sig[0] as i32 - + edostep_counts[1] * step_sig[1] as i32 - + edostep_counts[2] * step_sig[2] as i32 <= ed_bound + edostep_counts[0] * step_sig[0] as i32 + + edostep_counts[1] * step_sig[1] as i32 + + edostep_counts[2] * step_sig[2] as i32 + <= ed_bound && aber_lower <= aber_size && aber_size <= aber_upper }) diff --git a/src/words.rs b/src/words.rs index 564e6847..11967696 100644 --- a/src/words.rs +++ b/src/words.rs @@ -646,12 +646,7 @@ where + (1..slice.len()) .map(|i| slice.iter().take(i).cycle()) .take_while(|iter| { - slice.to_vec() - != iter - .clone() - .take(slice.len()) - .cloned() - .collect::>() + slice.to_vec() != iter.clone().take(slice.len()).cloned().collect::>() }) .collect::>() .len(); @@ -668,14 +663,12 @@ where /// The chirality of a scale word. pub fn chirality(word: &[Letter]) -> Chirality { - let mut modes = rotations(word); - modes.sort_unstable(); + let mut least_mode = least_mode(word); let word_rev: Vec = word.iter().cloned().rev().collect(); - let mut modes_rev = rotations(&word_rev); - modes_rev.sort_unstable(); - - match modes[0].cmp(&modes_rev[0]) { + let least_mode_word_rev = least_mode(&word_rev); + + match least_mode.cmp(&least_mode_word_rev) { Ordering::Less => Chirality::Right, Ordering::Equal => Chirality::Achiral, Ordering::Greater => Chirality::Left,