Skip to content

Commit

Permalink
Use sum() since it is now part of standard rust
Browse files Browse the repository at this point in the history
It wasn't available when I was first working on this code, it is now, so
hooray!

Also implemented as sum::<f64> since the type inference doesn't quite
work in this context. Related discussion to this issue can be found on
github here: rust-lang/rust#25094
  • Loading branch information
amacd31 committed Nov 28, 2017
1 parent e6ed2b7 commit 043e7eb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub fn rmse(obs: &[f64], sim: &[f64]) -> f64 {
*/
pub fn nse(obs: &[f64], sim: &[f64]) -> f64 {

let m: f64 = obs.iter().fold(0f64, std::ops::Add::add) / (obs.len() as f64);
let m: f64 = obs.iter().sum::<f64>() / (obs.len() as f64);

//int t;
let mut e1: f64 = 0.0;
Expand Down

0 comments on commit 043e7eb

Please sign in to comment.