sword_smith icon

normalize

sword_smith | PRO | 06/29/21 09:54:58 PM UTC (Edited) | 0 ⭐ | 829 👁️ | Never ⏰ | []
Rust |

1.14 KB

|

None

|

0 👍

/

0 👎

    pub fn normalize4(&mut self) {
        while !self.coefficients.is_empty() && self.coefficients.last().unwrap().is_zero() {
            self.coefficients.pop();
        }
    }
 
    pub fn normalize1(&mut self) {
        let mut remove = true;
        while remove {
            remove = match self.coefficients.last() {
                None => false,
                Some(i) => i.is_zero(),
            };
            if remove {
                self.coefficients.pop();
            }
        }
    }
 
    pub fn normalize2(&mut self) {
        loop {
            match self.coefficients.last() {
                None => {
                    break;
                }
                Some(i) => {
                    if i.is_zero() {
                        self.coefficients.pop();
                    } else {
                        break;
                    }
                }
            }
        }
    }
 
    pub fn normalize3(&mut self) {
        if !self.coefficients.is_empty() && self.coefficients.last().unwrap().is_zero() {
            self.coefficients.pop();
            self.normalize()
        }
    }

Comments