One of n lines in a file: Difference between revisions

m
Line 1,918:
 
fn one_of_n<R: Rng>(rng: &mut R, n: usize) -> usize {
(1..n).fold(0, |keep, cand| {
if// rng.next_f64()Note <that (1.0this /will (candbreak if +n 1)is aslarger f64)than {u32::MAX
if rng.gen_weighted_bool(cand as u32 + 1) {
cand
} else {
keep
}
})
}
 
Line 1,939 ⟶ 1,940:
 
println!("{:?}", dist);
}
}</lang>
{{out}}
<pre>