Skip to content

Commit 4094e4a

Browse files
committed
Make number of bins configurable on the command line
1 parent d05ee3d commit 4094e4a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/histogram.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ A module for Histograms
1010
let data = vec![0.3, 0.5, 6.4, 5.3, 3.6, 3.6, 3.5, 7.5, 4.0];
1111
1212
// and create a histogram out of it
13-
let h = Histogram::from_vec(&data);
13+
let h = Histogram::from_vec(&data, 30);
1414
```
1515
1616
TODO:
@@ -32,12 +32,12 @@ pub struct Histogram {
3232
}
3333

3434
impl Histogram {
35-
pub fn from_vec(v: &[f64]) -> Histogram {
35+
pub fn from_vec(v: &[f64], num_bins: u32) -> Histogram {
3636

3737
let max = v.iter().fold(-1. / 0., |a, &b| f64::max(a, b));
3838
let min = v.iter().fold(1. / 0., |a, &b| f64::min(a, b));
3939

40-
let num_bins = 30; // Number of bins
40+
let num_bins = num_bins as usize;
4141

4242
let mut bins = vec![0; num_bins];
4343

0 commit comments

Comments
 (0)