Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- let vector = vec![1.025_f64, 1.028, 1.03, 1.05, 1.051];
- let minimum =
- vector.windows(2)
- .map(|slice| (slice[0] - slice[1]).abs())
- .min_by(|x, y| x.partial_cmp(y).unwrap());
- println!("{:?}", minimum);
- }
Add Comment
Please, Sign In to add comment