Code for billiard scales: Difference between revisions
| Line 502: | Line 502: | ||
//! 3. For each region, trace a trajectory and record which coordinate changes | //! 3. For each region, trace a trajectory and record which coordinate changes | ||
//! 4. The sequence of changes (0=L, 1=m, 2=s) forms the scale word | //! 4. The sequence of changes (0=L, 1=m, 2=s) forms the scale word | ||
//! # Properties | //! # Properties | ||
//! | //! | ||
| Line 566: | Line 550: | ||
/// Rotate a scale word left by `degree` positions (change mode). | /// Rotate a scale word left by `degree` positions (change mode). | ||
pub fn rotate<T: std::clone::Clone>(slice: &[T], degree: usize) -> Vec<T> { | pub fn rotate<T: std::clone::Clone>(slice: &[T], degree: usize) -> Vec<T> { | ||
let degree = degree % slice.len(); | let degree = degree % slice.len(); | ||
| Line 586: | Line 560: | ||
/// The lexicographically least mode of a word (where the letters are in their usual order). | /// The lexicographically least mode of a word (where the letters are in their usual order). | ||
pub fn least_mode(scale: &[Letter]) -> Vec<Letter> { | pub fn least_mode(scale: &[Letter]) -> Vec<Letter> { | ||
rotate(scale, booth(scale)) | rotate(scale, booth(scale)) | ||
| Line 847: | Line 811: | ||
/// * `b` - Number of m (medium) steps | /// * `b` - Number of m (medium) steps | ||
/// * `c` - Number of s (small) steps | /// * `c` - Number of s (small) steps | ||
/// # Returns | /// # Returns | ||
/// | /// | ||