2.81 Find rows in matrix with zeros in them, and then remove the zeros

Given \(A = \{\{1, 0, 9\}, \{5, 0, 6\}, \{4, 1, 9\}, \{7, 0, 11\}, \{8, 1, 2\}\}\)

Find rows with zero in middle, and then remove the zeros from these found.

The result should be \(\{\{1, 9\}, \{5, 6\}, \{7, 11\}\}\)

Mathematica

Many ways to do this. See this

Remove["Global`*"] 
A = {{1, 0, 9}, {5, 0, 6}, {4, 1, 9}, {7, 0, 11}, {8, 1, 2}}; 
Cases[A,{x_,0,y_}:>{x,y}]
 

{{1, 9}, {5, 6}, {7, 11}}

Maple

restart; 
A := {{1, 0, 9}, {5, 0, 6}, {4, 1, 9}, {7, 0, 11}, {8, 1, 2}}; 
 
#One way is 
 
remove~(has,select(has,A,0),0) 
 
#Another way is 
 
f := x->remove(has,x,0); 
f~(select(has,A,0))
 

{{1, 9}, {5, 6}, {7, 11}}