mask

Syntax

mask(X, Y)

Details

Apply Y on each element of X. If the result is false, keep the element; if the result is true, change it to null. The result is of the same length as X.

Parameters

X is a scalar/vector/matrix.

Y is a conditional expression that generates true or false.

Returns

Returns an object identical to the input X (a scalar returns a scalar, a vector returns a vector of the same length, and a matrix returns a matrix of the same dimensions).

Examples

x=1..10
mask(x, x>6);
// output: [1,2,3,4,5,6,,,,]

m=matrix(1 2 3, 4 5 6, 7 8 9);
m;
#0 #1 #2
1 4 7
2 5 8
3 6 9
mask(m, m<6);
#0 #1 #2
7
8
6 9