Guest User

Untitled

a guest
May 27th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. extern crate chrono;
  2. extern crate time;
  3. extern crate itertools;
  4.  
  5. use chrono::prelude::*;
  6. use time::Duration;
  7. use itertools::Itertools;
  8.  
  9. fn main() {
  10. let t = vec![Utc::now(), Utc::now()-Duration::seconds(30), Utc::now()-Duration::seconds(65), Utc::now()-Duration::seconds(80)];
  11. let v = vec![10.0, 20.0, 40.0, 30.0];
  12.  
  13. let res = t.iter().zip(v.iter())
  14. .group_by(|(ts,_)| ts.minute())
  15. .into_iter()
  16. .filter_map(|(_, vs)| vs.map(|(_, &x)| x).minmax().into_option())
  17. .collect::<Vec<(f32,f32)>>(); // do not change type
  18.  
  19. println!("{:?}", res);
  20. }
Add Comment
Please, Sign In to add comment