Julia modulo of vector (or remainer of vector)

95 Views Asked by At

How do I obtain the modulo of a vector in Julia.

There are two ways in Julia to perform a modulo:

mod(9,5)

or equivalently:

9 % 5

However, neither works with a vector.

This also the came for computing the remainder of a vector.

1

There are 1 best solutions below

2
Bastiaan Quast On BEST ANSWER

For this you use the element-wise modulus operator .%:

[34,456,3] .% 2

Which gives:

3-element Vector{Int64}:
 0
 0
 1

EDIT: equivalently, you can use mod.()