Skip to content

Instantly share code, notes, and snippets.

@ricky-lim
Created February 28, 2023 20:11
Show Gist options
  • Save ricky-lim/9f88ce6901d821f04c5172c569803b66 to your computer and use it in GitHub Desktop.
Save ricky-lim/9f88ce6901d821f04c5172c569803b66 to your computer and use it in GitHub Desktop.
exponentiate a list of numbers
fn main() {
let mut v = vec![1, 2, 3, 4, 5];
let exp = 2;
for num in &mut v {
*num = i32::pow(*num, exp);
}
println!("{:?}", v);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment