This language bar is your friend. Select your favorite languages!
Select your favorite languages :
- Or search :
- Ada
- C
- Clojure
- Clojure
- Clojure
- Clojure
- C++
- C++
- C#
- D
- Dart
- Dart
- Elixir
- Fortran
- Go
- Haskell
- JS
- Java
- Java
- Lisp
- Lua
- PHP
- Pascal
- Perl
- Python
- Python
- Python
- Ruby
- Rust
- Rust
- Scala
elements = elements.stream()
.map(x -> x * c)
.toList();
elements = [c * x for x in elements]
This maps the lambda function that multiplies a number by c to the list elements , and overwrites the old list
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.