News

New paper! in the American Naturalist

Sunday, July 19, 2020

Element-wise operations of Arrays in Julia

How to compare elements in different arrays, and how to change elements based on the comparison

a = [1 2];
b = [10 -10];

a[a .> 1]
> [0 1] # [false true]

a[a .> 1] = 100;
# a is now [1 100]

b[a .> 1] = 0;
# b is now [10 100]