Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Rust
let elements = elements.into_iter().map(|x| c * x).collect::<Vec<_>>();
elements.iter_mut().for_each(|x| *x *= c);

It is possible to multiply the elements of the vector in-place, assuming you own the vector, or that you have mutably borrowed it.
for E of elements loop
   E := E * c;
end loop;

New implementation...
< >
Bzzzzzzzzz