Skip to content

Instantly share code, notes, and snippets.

@jmcph4
Created September 13, 2024 02:18
Show Gist options
  • Select an option

  • Save jmcph4/c42d70fb487e8a744ebd529ffdf6ecc4 to your computer and use it in GitHub Desktop.

Select an option

Save jmcph4/c42d70fb487e8a744ebd529ffdf6ecc4 to your computer and use it in GitHub Desktop.
fn foo(x: &[f64], y: &[f64], out: &mut [f64]) {
if x.len() != y.len() || x.len() != out.len() {
return;
} else {
let n: usize = x.len();
for i in 0..n {
out[i] = x[i] * y[i];
}
}
}
fn main() {
let x = [1.0, 2.0, 3.0];
let y = [4.0, 4.0, 4.0];
let mut z = [0.0;3];
foo(&x, &y, &mut z);
println!("{x:?} * {y:?} = {z:?}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment