2.22 find rows in a matrix based on values in different columns

Example, given Matrix

     1     9     0    10 
     5     6     7     8 
     3     9     2    10
 

Select rows which has \(9\) in the second column and \(10\) in the last column. Hence the result will be the first and third rows only

      1     9     0    10 
      3     9     2    10
 

Mathematica

mat={{1,9,0,10}, 
      {5,6,7,8}, 
      {3,9,2,10}}; 
 
p = Position[mat[[All,{2,4}]],x_/;x==={9,10}]
 

{{1},{3}}
 

Extract[mat,p]
 

 {{1,9,0,10}, 
  {3,9,2,10}}
 

 

Matlab

A=[1 9 0 10; 
   5 6 7 8; 
   3 9 2 10]; 
 
r=bsxfun(@eq,A(:,[2 4]),[9 10]); 
ind=all(r,2); 
A(ind,:)
 

ans = 
     1     9     0    10 
     3     9     2    10
 

 

Maple

restart; 
A:=Matrix([[1,9,0,10],[5,6,7,8],[3,9,2,10]]); 
nRow:=op([1,1],A); 
<seq(`if`(A[i,2]=9 and A[i,-1]=10,A[i,..],NULL),i=1..nRow)>; 
 
#OR 
restart; 
A:=Matrix([[1,9,0,10],[5,6,7,8],[3,9,2,10]]); 
nRow:=LinearAlgebra:-RowDimension(A); 
my_rows:=[seq(`if`(A[i,2]=9 and A[i,-1]=10,convert(A[i,..],list),NULL),i=1..nRow)]; 
Matrix(my_rows)
 

\[ \left [\begin {array}{cccc} 1 & 9 & 0 & 10 \\ 3 & 9 & 2 & 10 \end {array}\right ] \]

 

There does not seem to be a direct way in Maple to take list of row Vectors, and use these to make a Matrix. This is why I had to convert to list in the above to make it work.