ilastNot

Syntax

ilastNot(X)

Arguments

X is a vector, or a tuple of vectors of equal length, or a matrix.

Details

If X is a vector, return the subscript of the last non-NULL element. Return -1 if all elements are NULL.

If X is a tuple of vectors, return the subscript of the last position where the element in all vectors is not NULL.

If X is a matrix, return the subscript of the last non-NULL element within each column. The result is a vector.

Examples

ilastNot(NULL NULL 2 4 8 1 NULL);
// output
5

ilastNot(take(int(),5));
// output
-1

x=NULL NULL 4 7 8 NULL
y=1 NULL NULL 4 NULL NULL
ilastNot([x,y]);
// output
3

x=NULL NULL 4 7 8 NULL
y=1 2 NULL NULL NULL 6
ilastNot([x,y]);
// output
-1

m=matrix(2 NULL 1 0 NULL, NULL 2 NULL 6 0);
m;
#0 #1
2
2
1
0 6
0
ilastNot(m);
// output
[3,4]

Related functions: ifirstNot, lastNot, firstNot