Skip to content

Instantly share code, notes, and snippets.

@begetan
Created January 11, 2017 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save begetan/3dcd8b272b0baecd50877ed6e0ce52f5 to your computer and use it in GitHub Desktop.
Save begetan/3dcd8b272b0baecd50877ed6e0ce52f5 to your computer and use it in GitHub Desktop.
Simple test on Rust
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