fn sum_and_scale(a: &'static [(u8, f32)]) -> Vec<(u8, f32)> {
        let mut p = 0f32;
        let mut result: Vec<(u8, f32)> = a.iter().map(|e| {
            p += e.1;
            (e.0, p * LOOKUP_SCALE)
        }).collect();
        let result_len = result.len();
        result[result_len - 1].1 = LOOKUP_SCALE;
        result
    }
// Here the lookup table is part of the algorithm and needs the
// original probabilities (scaled with the LOOKUP_SCALE), because
// Isaac says so :-)
Here the lookup table is part of the algorithm and needs the
original probabilities (scaled with the LOOKUP_SCALE), because
Isaac says so :-)
Here the lookup table is part of the algorithm and needs the original probabilities ( scaled with the LOOKUP_SCALE ) because Isaac says so : - )
fn sum_and_scale(a: &'static [(u8, f32)]) -> Vec<(u8, f32)> {
        let mut p = 0f32;
        let mut result: Vec<(u8, f32)> = a.iter().map(|e| {
            p += e.1;
            (e.0, p * LOOKUP_SCALE)
        }).collect();
        let result_len = result.len();
        result[result_len - 1].1 = LOOKUP_SCALE;
        result
    }
fn sum_and_scale ( a : & ' static [ ( u8 , f32 ) ] ) -> Vec < ( u8 , f32 ) > { let mut p = 0f32 ; let mut result : Vec < ( u8 , f32 ) > = a . iter ( ) . map ( | e | { p += e . 1 ; ( e . 0 , p * LOOKUP_SCALE ) } ) . collect ( ) ; let result_len = result . len ( ) ; result [ result_len - 1 ] . 1 = LOOKUP_SCALE ; result }
Here the lookup table is part of the algorithm and needs the
original probabilities (scaled with the LOOKUP_SCALE), because
Isaac says so :-)
Here the lookup table is part of the algorithm and needs the original probabilities ( scaled with the LOOKUP_SCALE ) because Isaac says so : - )
a
&'static [(u8, f32)]