Created
February 28, 2023 20:11
-
-
Save ricky-lim/9f88ce6901d821f04c5172c569803b66 to your computer and use it in GitHub Desktop.
exponentiate a list of numbers
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
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