Created
January 11, 2017 19:01
-
-
Save begetan/3dcd8b272b0baecd50877ed6e0ce52f5 to your computer and use it in GitHub Desktop.
Simple test on Rust
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn lpv(iter_num: usize, sz: usize) -> usize { | |
let sums: Vec<_> = (0..iter_num) | |
.map(|_| { | |
let x: Vec<_> = (0..sz).map(|i| i).collect(); | |
let y: Vec<_> = x.iter().zip(x.iter().skip(1)).map(|(x, y)| x + y).collect(); | |
(0..sz).step_by(100).map(|i| y[i]).sum() | |
}) | |
.collect(); | |
*sums.last().unwrap() | |
} | |
fn main() { | |
println!("{:?}", lpa(20, 1000000)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment