fn normalise_bit_count<F>(data: &[usize], rule: F) -> usize
where
    F: Fn(usize, usize) -> bool,
{
    let mut result = 0;
    let bit_counts = count_bits(data);
    let threshold = (data.len() as f64 / 2.0).round() as usize;

    for (i, count) in bit_counts.into_iter().enumerate() {
        if rule(count, threshold) {
            // left-shift 1 bit by the current index to the position of the bit we want to set high
            result |= 1 << i;
        }
    }

    result
}
// Counts high bits across the data set and normalises according to the rule
Counts high bits across the data set and normalises according to the rule
Counts high bits across the data set and normalises according to the rule
fn normalise_bit_count<F>(data: &[usize], rule: F) -> usize
where
    F: Fn(usize, usize) -> bool,
{
    let mut result = 0;
    let bit_counts = count_bits(data);
    let threshold = (data.len() as f64 / 2.0).round() as usize;
    for (i, count) in bit_counts.into_iter().enumerate() {
        if rule(count, threshold) {
            // left-shift 1 bit by the current index to the position of the bit we want to set high
            result |= 1 << i;
        }
    }
    result
}
fn normalise_bit_count < F > ( data : & [ usize ] , rule : F ) -> usize where F : Fn ( usize , usize ) -> bool , { let mut result = 0 ; let bit_counts = count_bits ( data ) ; let threshold = ( data . len ( ) as f64 / 2.0 ) . round ( ) as usize ; for ( i , count ) in bit_counts . into_iter ( ) . enumerate ( ) { if rule ( count , threshold ) { // left-shift 1 bit by the current index to the position of the bit we want to set high result |= 1 << i ; } } result }
Counts high bits across the data set and normalises according to the rule
Counts high bits across the data set and normalises according to the rule
data
&[usize]
rule
F