[Question]
  [
Your challenge is to, given a matrix of nonnegative integers, remove all rows and columns that contain a 0.
For example, with this matrix:
```
[[5, 3, **2**, 4, **1**],
 [**3**, **2**, **0**, **4**, **7**],
 [7, 1, **9**, 8, **2**],
 [3, 2, **1**, 5, **7**],
 [6, 4, **6**, 1, **2**],
 [**9**, **3**, **2**, **4**, **0**]]
```
Columns 3 and 5, along with rows 2 and 6 (in bold), contain a 0, so they should be removed, leaving:
```
[[5, 3, 4],
 [7, 1, 8],
 [3, 2, 5],
 [6, 4, 1]]
```
You may assume the input and the output are nonempty. This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), shortest wins!
## Testcases
```
[[1, 2, 3], [4, 5, 6]] -> [[1, 2, 3], [4, 5, 6]]
[[1, 2, 3], [4, 5, 0]] -> [[1, 2]]
[[3, 6, 19], [4, 0, 18], [2, 19, 3]] -> [[3, 19], [2, 3]]
[[5, 3, 2, 4, 1], [3, 2, 0, 4, 7], [7, 1, 9, 8, 2], [3, 2, 1, 5, 7], [6, 4, 6, 1, 2], [9, 3, 2, 4, 0]] -> [[5, 3, 4], [7, 1, 8], [3, 2, 5], [6, 4, 1]]
[[4, 9, 4, 1], [2, 0, 6, 0], [3, 4, 1, 2], [9, 7, 8, 5], [3, 5, 2, 0]] -> [[4, 4], [3, 1], [9, 8]]
```
  
[Answer]
# [R](https://www.r-project.org), 35 bytes
```
\(x,`?`=\(d)apply(x,d,all))x[?1,?2]
```
[Attempt This Online!](https://ato.pxeger.com/run?1=fVFdasMwDGavPYWhLxaoYDt2mhWyXGJvqaFhJTBIoJQW0rPsJRvsUBvsLrPkuCQwBiaWpe8v9tv7efxoy8_rpd0UX-u9HPBQHcq9PEJzOnW3cD5i03UAQ11prIyP0O-HH9mXfXM5vw7yRaqdNqh2OaAFWLWyhxV901ijMCgyFBaFQxFgBvEZYC02T6Kup7FHUU8A7_-hqz_oS0KA5ij0IzNUqApWoEYGmM3JGbXJmRMsVBx7GhbRqVZ83PIKzaBYpHSGO45HOcNy7hiG3aVC_HyeINpYyhA1Cyoj3FEZtfQynGVRmwwUm6l0S3fXLeeLFi4iAd3c3k7edBG00x_56ZXHMe6_)
---
Alternative solution if the input contained `NA`s instead of `0`s:
### [R](https://www.r-project.org), 34 bytes
```
\(x,`?`=complete.cases)x[?x,?t(x)]
```
[Attempt This Online!](https://ato.pxeger.com/run?1=fVHdSsMwFMbbPUXQmxw4kzRNujqoxRfwyrta2CjpGKxsrBXyLt5UwYfS9_De5KQdLQwhNCfnfH9N3j_O_ecu-3rr6mX6ffvKLW7yTVYdm9PBdOa-2ramBVvkFvOOWygD8ufmt84cGHZ8X5tDaxzP4vMTwII3WbPtznvLKy7WkUSxTgCVm9S8gYX_juMImUQWI1PINDIHk4gvAHds-ciKYhiXyIoBUJb_0MUV-pzgoAmy6IEYwlUpKfhGDBhPybFve2dKMFPR5ClJJBprQccVLdd0iumYTlJH0yghWEIdSbCLlIufTBMEG-UzBM3UlwGufRm0onk4RaJqNBBkJsZburiuKF-w0AEJqKf2avD2F-F3_0fl8Pp9H_Y_)
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 11 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
¬¨≈í·π™Z≈ìP@·∫éZ…ó∆í
```
A monadic Link that accepts the matrix and yields the reduced matrix.
**[Try it online!](https://tio.run/##y0rNyan8///QmqOTHu5cFXV0coDDw119USenH5v0/3C7@///0dGmOgrGOgpGOgomOgqGsTpcCtEQrgFYxBwsYg6U0lGw1FGwAErB1BiABU1haszA6s3AghA1lkgmGwBFYgE "Jelly ‚Äì Try It Online")**
### How?
```
¬¨≈í·π™Z≈ìP@·∫éZ…ó∆í - Link: list of lists of integers, M
¬¨           - logical NOT (vectorises)
 ≈í·π™         - truthy multidimensional indices
   Z        - transpose -> [zero row indices, zero column indices]
          ∆í - start with {M} and reduce {that} by:
         …ó  -   last three links as a dyad - f(Current, Indices):
      @     -     with swapped arguments:
    ≈ìP      -       partition {Current} at {Indices}
       ·∫é    -     tighten
        Z   -     transpose
```
[Answer]
# [MATL](https://github.com/lmendo/MATL), 10 bytes
```
t!XAyXA3$)
```
Try at [MATL online](https://matl.io/?code=t%21XAyXA3%24%29&inputs=%5B5%2C+3%2C+2%2C+4%2C+1%3B+3%2C+2%2C+0%2C+4%2C+7%3B+7%2C+1%2C+9%2C+8%2C+2%3B+3%2C+2%2C+1%2C+5%2C+7%3B+6%2C+4%2C+6%2C+1%2C+2%3B+9%2C+3%2C+2%2C+4%2C+0%5D&version=22.8.0)! Or [verify all test cases](https://matl.io/?code=%60%0At%21XAyXA3%24%29%0A0cXDT&inputs=%5B1%2C+2%2C+3%3B+4%2C+5%2C+6%5D%0A%5B1%2C+2%2C+3%3B+4%2C+5%2C+0%5D%0A%5B3%2C+6%2C+19%3B+4%2C+0%2C+18%3B+2%2C+19%2C+3%5D%0A%5B5%2C+3%2C+2%2C+4%2C+1%3B+3%2C+2%2C+0%2C+4%2C+7%3B+7%2C+1%2C+9%2C+8%2C+2%3B+3%2C+2%2C+1%2C+5%2C+7%3B+6%2C+4%2C+6%2C+1%2C+2%3B+9%2C+3%2C+2%2C+4%2C+0%5D%0A%5B4%2C+9%2C+4%2C+1%3B+2%2C+0%2C+6%2C+0%3B+3%2C+4%2C+1%2C+2%3B+9%2C+7%2C+8%2C+5%3B+3%2C+5%2C+2%2C+0%5D&version=22.8.0).
### How it works
```
t      % Implicit input. Duplicate
!      % Transpose
XA     % Vertical-all: gives a logical vector containing true
       % for columns without zeros, or false otherwise
y      % Duplicate from below: pushes copy of input 
XA     % Vertical-all
3$)    % 3-input indexing: keeps the selected rows and columns
       % Implicit display
```
[Answer]
# [Python](https://www.python.org) + numpy, 32 bytes
```
lambda a:a[a.all(1)][:,a.all(0)]
```
[Attempt This Online!](https://ato.pxeger.com/run?1=bZJNTsMwEIUlljnF7GJLbpT0v5HSiwQvDE2oIbUtx0XkLGwqIbgTnAaPXdqKNpvMvO_NGyvO-5cZ3Farw0db3X_uXTtafkMndg8bAaIUtchE15GC8rpksc4pj76fu-eNcKJK07SuCwZjBhPOoJ4ymDGYcw6jNdwmyQ05vxwIlon3MihWR0_u6yXWYxRx9jgw-TOFQJz0cZOQ78cKJLHLg7BAYeEBA5-yxG0nRxGOEhzzYJ4HLThWF6Gnw8ZN03Pk8hw2O8cUnPvPlCRyZ7R1oPY7M4DoQZnENb3rofJZymTCWjGQ5lV0ZCu6NuudlYZQSqHVFlACqaCTqsl600lH0tE6pTxQVJHipUSKSk8oTxLkkmnEYV-ZgH8Gv7YlkoZGvwjsia6qgYabjrqxUjmCNPayBaVdsMeUsyltrNW2TOl_XSqzd2XKQF6h5s00j67ZINVX9EmHsYHGX-5wiO9f)
-6 bytes thanks to att
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 15 bytes
```
((‚ç∏0‚â†‚àß/)¬®‚ä¢‚çÆ‚çâ)‚å∑‚ä¢
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/X0PjUe8Og0edCx51LNfXPLTiUdeiR73rHvV2aj7q2Q7k/Hd71DbhUW/fo67mR71rHvVuObTe@FHbxEd9U4ODnIFkiIdnMEgNSMQr2N9PPTraUEfBSEfBOFZHIdpER8FUR8EsNladS12di4AyA6zKjIH6dRQMLaHqDIBsCxDbCCQI0o9NE9A0Y7DxQB2GINUQngFYwBwkYA6U0FEAGmABlEGoMAS7BKzCDKzYDCwGVmGJZCjIrQA "APL (Dyalog Extended) ‚Äì Try It Online")
# [APL (Dyalog APL)](https://www.dyalog.com/products.htm), ~~19~~ ~~18~~ ~~17~~ 16 bytes
-1 byte thanks to [@att](https://codegolf.stackexchange.com/users/81203/att)
```
‚ä¢‚å∑‚ç®B‚àò‚çâ,B‚Üê‚äÇ‚àò‚ç∏0‚â†‚àß‚åø
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m70qpTIxJz89PrEgZ8EqK7_E3NTigsTk1KWlJWm6Fjc1HnUtetSz_VHvCqdHHTMe9XbqOD1qm_CoqwnM22HwqHPBo47lj3r2LylOSi6-xejhBpLu7TN61NX8qG9qcJAzkAzx8Azm4gIygHJA-YlAllewv596dLShjoKRjoJxrI5CtImOgqmOgllsrDpUpbo6cVoMCGoxBpqro2BoCdVjAGRbgNhGIEGQWYQMANpiDLYWqNsQpBPCMwALmIMEzIESOgpAwyyAMggVhmAXglWYgRWbgcXAKiyRDAX7wco1LwUt_BcsgNAA)
```
‚ä¢‚å∑‚ç®B‚àò‚çâ,B‚Üê‚äÇ‚àò‚ç∏0‚â†‚àß‚åø¬≠‚Å°‚Äã‚Äé‚Å™‚Å™‚Å†‚Å™‚Å™‚Å†‚Å™‚Å™‚Å†‚Å™‚Å™‚Å†‚Å™‚Å™‚Å†‚Å™‚Å™‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å§‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å°‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å¢‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å£‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å§‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å°‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å¢‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å£‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å§‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Äã‚Äé‚Å™‚Å™‚Å†‚Å™‚Å™‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å£‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å§‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å£‚Äã‚Äé‚Å™‚Å™‚Å†‚Å™‚Å™‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å°‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å¢‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å§‚Äã‚Äé‚Å™‚Å™‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å§‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Å°‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å¢‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Å¢‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å°‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å¢‚Å™‚Äè‚Å†‚Å™‚Å™‚Å†‚Å™‚Å™‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Å£‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å£‚Å™‚Äè‚Å†‚Å™‚Å™‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Å§‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å§‚Å™‚Äè‚Å†‚Å™‚Å™‚Å†‚Å™‚Å™‚Å†‚Å™‚Å™‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å£‚Å°‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å°‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å™‚Äè‚Å†‚Å™‚Å™‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å°‚Å°‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå¬≠
       B‚Üê‚äÇ‚àò‚ç∏0‚â†‚àß‚åø  ‚çù ‚Äé‚Å°B = Monadic function to get indices of columns without zeros:
              ‚àß‚åø  ‚çù ‚Äé‚Å¢  reduce each column on lcm
            0‚â†    ‚çù ‚Äé‚Å£  check if not equal to 0 (vectorized)
           ‚ç∏      ‚çù ‚Äé‚Å§  get indices of true values
         ‚äÇ        ‚çù ‚Äé‚Å¢‚Å°  enclose
   B‚àò‚çâ            ‚çù ‚Äé‚Å¢‚Å¢Apply B on transpose (first result)
      ,           ‚çù ‚Äé‚Å¢‚Å£catenate with
       B          ‚çù ‚Äé‚Å¢‚Å§Apply B on argument (second result)
‚ä¢‚å∑‚ç®               ‚çù ‚Äé‚Å£‚Å°Keep only rows and columns in first and second result respectively
üíé
```
Created with the help of [Luminespire](https://vyxal.github.io/Luminespire).
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), ~~18~~ ~~16~~ 15 bytes
-1 thanks to [coltim](https://codegolf.stackexchange.com/questions/269954/remove-falsy-rows-and-columns#comment585700_269964)
```
{x.&'1&/''+:\x}
```
[Try it online!](https://ngn.codeberg.page/k#eJxVTjkOwkAM7POKqbJESGDvmY2/Qp03REL8nfEmEqKy59Ts2/t4zEHnZwj37XV8pmnHTRGRLKOgLv9YBk6o0E5CoKtF/khDKEi0Zqj5FX7NGhQdK+LglCXNKhVWkOtX4izOdHrasxXCRL5cjQ2FuHjvbxR9cg7zhLmrQzlLly/B6SfN)
```
     1&/''+:\x      row-,column-wise zero-free?
   &'               indices where true
 x.                 submatrix
```
[Answer]
# [Matlab](https://www.mathworks.com/products/matlab.html), ~~74 bytes(?)~~ 52 bytes
*-22 bytes thanks to Luis Mendo because my first attempt was too readable.*
[Try it online!](https://octav.onl/mbfvo809) Input for first test case would be `F([1,2,3;4,5,6])`
To be honest, I just wanted to try the challenge and am pleasantly surprised to how neatly it can be solved Matlab, so I just wanted to share it.
```
function[m]=F(m);[r,c]=find(~m);m(r,:)=[];m(:,c)=[];
```
[Answer]
# [Python 3](https://docs.python.org/3/), ~~82~~ ~~74~~ ~~65~~ 60 bytes
*-13 bytes thanks to [Mukundan314](https://codegolf.stackexchange.com/users/91267). -9 bytes thanks to [att](https://codegolf.stackexchange.com/users/81203).*
```
lambda m:[q for*q,r in zip(*filter(all,zip(*m)),m)if all(r)]
```
[Try it online!](https://tio.run/##bZBNDsIgEIX3PcUswcyCFm3VpCdBFjVKJOmfyEYvX4dp1WhkQZg337xHZrzHy9DrydWHqW2646mBbm@u4IawumIA38PDj2LlfBvPQTRti1x3UmInvQNSRJB2iudbvEENxpgcoUDQFsGsETYIpbWYwev8AdQPoGkGId8thKL3Nr2LJKbJb5wQUunOF0jxvEqVnhuUmCrCKoQthS69DX/lN59UzY2X51wpFqokVOy5Y6/iQ@TsyETJcPmV/TalQJtltGSIacW8vD3/YAy@j8KJKOX0BA "Python 3 ‚Äì Try It Online")
I wasn't going to post two answers but since nobody else is posting a Python answer that *doesn't* rely on NumPy... Port of [my Haskell answer](https://codegolf.stackexchange.com/a/269969), but I can't really take any credit for the final result. It all goes to [Mukundan314](https://codegolf.stackexchange.com/users/91267) and [att](https://codegolf.stackexchange.com/users/81203). I'll try my best to explain this wizardry.
## Explanation
Said wizardry *really* takes advantage of Python's splat operator `*`. What it does essentially is unpack an iterable (in this case a two-dimensional list) into separate arguments for a function call. Let's start with a simple matrix `m`, and I'll document the transformations that happen to it along the way.
```
[[4, 9, 4, 1],
 [2, 0, 6, 0],
 [3, 4, 1, 2],
 [3, 5, 2, 0]]
```
First, `zip(*m)` transposes the list. Instead of passing `m` to the `zip` function as the list of rows it is, it's passed as separate arguments, effectively zipping the rows of the matrix together to create a list of the columns.
```
[(4, 2, 3, 3),
 (9, 0, 4, 5),
 (4, 6, 1, 2),
 (1, 0, 2, 0)]
```
Next, `filter(all, ...)` removes every column that has a zero in it by checking `all` of the column against Python's boolean logic: 0 is falsy and every other number is truthy. (Hey, that's half the challenge sorted!)
```
[(4, 2, 3, 3),
 (4, 6, 1, 2)]
```
Cool, that's the truthy columns. After that, `zip(*..., m)` is once again splatting the previous result and zipping it together with the original input. This basically transposes it back to the rows, except without the falsy columns, and then prepends it to the original rows.
```
[(4, 4, [4, 9, 4, 1]),
 (2, 6, [2, 0, 6, 0]),
 (3, 1, [3, 4, 1, 2]),
 (3, 2, [3, 5, 2, 0])]
```
Here comes an interesting bit. Remember what I said about the splat operator? Yeah, it does more than that. Kinda. `for *q, r in ...` effectively groups the rows-without-falsy-columns together, while keeping the original rows separate. The splat operator "collects" elements into `q` when iterating over something until another argument `r` is required.
```
[([4, 4], [4, 9, 4, 1]),
 ([2, 6], [2, 0, 6, 0]),
 ([3, 1], [3, 4, 1, 2]),
 ([3, 2], [3, 5, 2, 0])]
```
Now all that's left to do is get rid of the falsy rows and to do this, `q ... if all(r)` employs a similar trick to when the falsy columns were removed. While iterating over the previous result, if and only if `r` (or the original row) is truthy, keep `q`.
```
[[4, 4],
 [3, 1]]
```
[Answer]
# Google Sheets, 72 bytes
```
=let(a,A1:E6,_,lambda(x,min(x)),filter(filter(a,byrow(a,_)),bycol(a,_)))
```
Put the array in cells `A1:E6` and the formula in cell `G1`.
![filter rows and columns.png](https://i.imgur.com/RbcSOKP.png)
In Google Sheets, a formula cannot return a *completely empty* 2D array. When all rows or columns contain a zero, the formula will error out.
[Answer]
# JavaScript (ES6), 62 bytes
*-2 thanks to [@l4m2](https://codegolf.stackexchange.com/users/76323/l4m2)*
```
m=>(g=a=>a.filter((v,x)=>(+v?m:v).every(v=>v[x]|v)))(m).map(g)
```
[Try it online!](https://tio.run/##hY7LCsIwEEX3fkWWGRxD02ofQuqHhC5CTYvSF20JFfz3mkRBFwV3M2fOvcxdGTWV422YD11/1Wsl1lbktBZK5IpVt2bWI6UGF7B0by7t2QDTRo8PakRu5FI8DQDQFlirBlrDWvbd1DeaNX1NKyolRxIiiQok8ojkhCQuCoDdXy3Y1CKbR8KzjxfYOXVz6KDLb4VsW@TrbYI7@70FHiQOJPaAxBak9vI1uP/EG7GXY8@8kf2U@l/XFw "JavaScript (Node.js) ‚Äì Try It Online")
### Commented
```
m => (               // m[] = input matrix
  g = a =>           // g is a helper function taking an array a[]
  a.filter((v, x) => // for each value v at index x in a[]:
    (+v ? m          //   if v is atomic, we use m[] (2nd pass on columns)
            : v)     //   otherwise, we use v (1st pass on rows)
    .every(v =>      //   for each value v in the array chosen above:
      v[x]           //     test either v[x] (when removing columns)
      | v            //     or v (when removing rows)
    )                //   end of every()
  )                  // end of filter()
)(m)                 // invoke g on m[] to remove rows
.map(g)              // invoke g on each row to remove columns
```
[Answer]
# [J](http://jsoftware.com/), 15 bytes
```
*@*/#"1*@*/"1#]
```
[Try it online!](https://tio.run/##ZYzLCsIwEEX3fsUlFYthmkc1qQ1VgoKr4sJ9FyIWceMPSH89JulGcDHMnXMu8wpMlCP2DiUICi5OJXC69ufAPZcF02kxXQxhvbgcBW7u4CsxDZ2PblIdl6uP45LLbP/p4/58Y4SFwRKGsCHUhC1B0xxVvhpqEkJL2CU8uwhMcjZ3bAY1tT9fVPgC "J ‚Äì Try It Online")
* `*@*/"1` Boolean multiply across columns...
* `#]` and use that to filter rows.
* `#"1` then filter each of those remaining rows...
* `*@*/` by the boolean filter obtained by multiplying all the rows together
[Answer]
# [Haskell](https://www.haskell.org) + [hgl](https://gitlab.com/wheatwizard/haskell-golfing-library), 38 bytes
```
f y=cr<<fn(e 0<(tx y!)<st)<eu<fn(e 0)y
```
[Attempt This Online!](https://ato.pxeger.com/run?1=bVBLasMwFKRbn2KyKTYoINuN7RT5CIXsjRemkYipnSa2DPVZuvGm9EzpaSo9KQmFbqQ3nzcD7_P70IxvsuuWy6rtT--Dxi7ww3lqula1co_dILtpL78mrdbF5VFhLl8HIdQxlOAi1B-YV5EYdSTk5Nlodu6fh2ctRz2iDIAKVRUzJAxpzVA9MWwYsro2EvtP4jcpNT6GeOs1bubCzokl7c7VaESDzRt7mdMmtyh1gmmxyNhyhsIUeW1D9fdOg1OirmkOcSJyS-SUtqWU5O6IKYscGZmzP623UFdVB0HftEeU6F8QngYIqAh0NHfCZXH_Lw)
## Alternate, 43 bytes
```
cr<<<g st<g cr<m(sQ<oti mn)
```
```
g=tx><fn<e 0<<m
```
[Attempt This Online!](https://ato.pxeger.com/run?1=TY69DoIwFIX3PsV1g6QkgIshF3cHE5ybDkRabGwBaUncfBAXFuMz8TY2QNTlnpPv3L_n-1Laq9B6nDbKdG3v4DaUWkklKih6oYdKkDUoXoOT0W6KZH7uEbEG63zx3gT2hK1TYJqQ1Lm771E2KCBGNOvQwwnrLGQZMMYOjeOckwXlBIB5mtCYJpyy9KtbmvouADqnKff6j-JfODtOiClVMy80Rwi6HhBkCPOZ5Y1xXPQD)
I kind of understand how it works but it's not easy to explain. First it tags each value with the minimum in its row, then it removes every column with a zero, then it removes every row with a zero tag.
* `m(sQ<oti mn)` is the part that adds the tags.
* `g cr` is the part that removes the columns (it also transposes the matrix)
* `g st` is that part that removes the rows (it also transposes the matrix back)
* `cr` removes the tags.
# Reflection
* There should be a non-infix version of `(!)`.
* There should be precomposed versions of `e` and `ne`.
* `oti` should probably have a 2 byte name.
* The precendence of `@!` makes it incompatible with composition. I should tweak this.
* There is already an "index map" a couple of index filters would be nice.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~15~~ 14 bytes
```
‚≠Ü¬πÔº•Œ¶Œ∏Œ†ŒªŒ¶Œª‚¨§Œ∏¬ßœÄŒæ
```
[Try it online!](https://tio.run/##TYxBC4JAEIXv/Yp33IUJtFKTTl6CDoHQcdmDqJQwqC1b@O@3dZVwLo/5vjdTvypTDxU7V5qut@JhfTzv1ShiwhzXjm1rxJtQmqH51FawlIQVM6Fgnm1hb33TTmIkTDLMxTmlVEI4Eg6EEyHWtAPUskcBZQvKvCTkhLN325anyb@VhpM00LWVb95HWmu3//IP "Charcoal ‚Äì Try It Online") Link is to verbose version of code. Explanation:
```
    Œ∏          Input array
   Œ¶           Filtered where
      Œª        Current row
     Œ†         Product (is truthy if the row contains no zeros)
  Ôº•            Map over remaining rows
        Œª       Current row
       Œ¶        Filtered where
            œÄ   Inner row
           ¬ß    Indexed by
             Œæ  Current column
         ‚¨§      Are non-zero for each row of
          Œ∏     Input array
‚≠Ü¬π              Pretty-print the result
```
[Answer]
# APL+WIN, 17 bytes
Prompts for input of matrix
```
(√ó/√óm)‚åø(√ó‚åø√óm)/m‚Üê‚éï
```
[Try it online! Thanks to Dyalog Classic](https://tio.run/##ZY1NCsIwEIX3OcXsqovSpvlpcwRB8QylUhFaFLrqBdSFihvpRdy76E1ykfgS4kpCMm9m3vtSn7p0N9bdcZ82XT0Mh8bZx2uztuenYFCrLRRn9npp3WKesnnql/b2gcTrm6yHAUYHC3MtK0jY@5sTKklSpFlCCfuf53EuwlyQJm6wyIlX8ECLaNCkYFCIFdjzUHOoEoeToSogEQG0BEZ6FHoTE7@PFElwJJlA8QyNK2JnkK3I/6L87gs "APL (Dyalog Classic) ‚Äì Try It Online")
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 11 bytes
```
(√ó‚àß/‚çÆ‚àß‚åø)‚çõ/‚ç®
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/X@Pw9Ecdy/Uf9a4DUo969ms@6p0N5K347/aobcKj3r5HXc2Petc86t1yaL3xo7aJj/qmBgc5A8kQD89gkBqQiFewv596dLShjoKRjoJxrI5CtImOgqmOgllsrDqXujoXAWUGWJUZA/XrKBhaQtUZANkWILYRSBCkH5smoGnGYOOBOgxBqiE8A7CAOUjAHCihowA0wAIog1BhCHYJWIUZWLEZWAyswhLJUJBbAQ "APL (Dyalog Extended) ‚Äì Try It Online")
`‚ç®`‚ÄÉusing the argument as both parameter (list of masks, one per dimension) and data
`/`‚ÄÉfilter the data using the parameter
`(`‚Ä¶`)‚çõ`‚ÄÉfirst pre-processing the paramter as follows:
‚ÄÉ`√ó`‚ÄÉsignum of
‚ÄÉ`‚àß/`‚ÄÉrow-wise LCM
‚ÄÉ`‚çÆ`‚ÄÉjuxtaposed with
‚ÄÉ`‚àß‚åø`‚ÄÉcolumn-wise LCM
[Answer]
# [R](https://www.r-project.org), 32 bytes
```
\(x)x[!rowSums(!x),!colSums(!x)]
```
[Attempt This Online!](https://ato.pxeger.com/run?1=fVHNSsQwEMarTzHFSwZmIUmTbF3Ql9BbzUEWCoLLQt3FvsteuoKvJOjTmJk0SwsiBDKZ-f6SnM79-NHdfR4P3ar5hic14NBW_f794bh7U9WAVG33r-UQM-7n6qtTu-dD_zKordIbY0lvApJDvJ4NDIElqAkcgSdIAEv0iHgDq3to22kcCdoJEOM_dP0HfUlI0EBgboWhU9WIAjdqpHpOrrnNzpJgoeLF04qIKbWW41pWaibFpqSz0vEyCgIL0rECu0il-GGeINs4zpA1Gy4z3HOZtcwynBNRVwy0mOnyShfXteTLFj4jkfzc3k3e_BC8843i9L3jmPdf)
Test suite stolen from [pajonk's answer](https://codegolf.stackexchange.com/a/269976/78274).
[Answer]
# [Haskell](https://www.haskell.org/), ~~81~~ ~~63~~ ~~62~~ 59 bytes
*-3 bytes thanks to [Wheat Wizard](https://codegolf.stackexchange.com/users/56656).*
```
n=notElem 0
f m=[[c|(x,c)<-zip[0..]r,n$map(!!x)m]|r<-m,n r]
```
[Try it online!](https://tio.run/##bZBBi4MwEIXv/opX2IPCVKJutUI99thfEHKQYlmpyYp6kNL/bidTd5eWzSFk3nzzXpiverw2XbcsrnLf07FrLFRwga20Pt/Dmc7RYXtre63i2AzkPmzdh5vNHFlzHw5bSw6DWaZmnEZU0NA6IaSEzBD0J2FHyI0JsB76D1BvQMYzhKRcCcXvvX@nXvSTrzgjrPKdrJCSeeWr7NngRF8xVhD2HLr2dvKV93xWM2n8eD4rJULhhUI8S/FK/4hEHIXIBc5fsn9NORAmCGzdOl4ab/SEsB9aNyHGJYJsc3kA "Haskell ‚Äì Try It Online")
~~I *really* want to use the fact that Haskell has `product` in Prelude but... Never mind, I did it. :P~~ Never mind, the original approach allows for code shorter by a byte due to syntactical rearrangement.
## Explanation (slightly outdated)
```
f m                            -- define function f that takes matrix m
  | n <- notElem =             -- alias notElem (element not in list) to p
    [[c                        --     store c
      | (x, c) <- zip [0..] r  --   for every pair of index x and value c in r...
      , n 0 $                  --   if 0 is not in the...
      map (!! x) m)            --   ...xth element of every row in m (column)
    | r <- m                   -- for every row r in m...
    , n 0 r]                   -- if 0 is not in r (truthy)
```
[Answer]
# [Uiua](https://uiua.org) [SBCS](https://tinyurl.com/Uiua-SBCS-Jan-14), ~~15~~ 14 bytes
```
‚çâ‚ñΩ‚äô‚çâ‚äô‚ñΩ‚à©/‚Üß‚üú‚çâ‚â†0.
```
[Try it!](https://uiua.org/pad?src=0_8_0__ZiDihpAg4o2J4pa94oqZ4o2J4oqZ4pa94oipL-KGp-KfnOKNieKJoDAuCgpmIFtbMSAyIDNdCiAgIFs0IDUgNl1dCgpmIFtbMSAyIDNdCiAgIFs0IDUgMF1dCgpmIFtbMyA2IDE5XQogICBbNCAwIDE4XQogICBbMiAxOSAzXV0KCmYgW1s1IDMgMiA0IDFdCiAgIFszIDIgMCA0IDddCiAgIFs3IDEgOSA4IDJdCiAgIFszIDIgMSA1IDddCiAgIFs2IDQgNiAxIDJdCiAgIFs5IDMgMiA0IDBdXQoKZiBbWzQgOSA0IDFdCiAgIFsyIDAgNiAwXQogICBbMyA0IDEgMl0KICAgWzkgNyA4IDVdCiAgIFszIDUgMiAwXV0K)
-1 thanks to the new `‚üú on` modifier that dropped this morning.
Keeps two masks on the stack of which rows should be kept on each axis, and filters the input matrix based on these.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 10 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
√∏DƒÄP√è√∏IƒÄP√è
```
[Try it online](https://tio.run/##yy9OTMpM/f//8A6XIw0Bh/sP7/AE0///R0eb6igY6ygY6SiY6CgYxuooREN4BmABc5CAOVBCR8FSR8ECKINQARQzhaowAys2A4uBVVgiGWoQGwsA) or [verify all test cases](https://tio.run/##bY3NCoJAFIX3PYW4PoHjz6hBuG6V62QWRRK2MLExcNcb9Bi9QITQTlv3SnZntCBoNWe@e79zD8f1Jkv7k7nIi0rODDOq5xMzLlMp62lRZrlMt0RRt9fV7nXbtw/0XVN3zfMcdxdK@u3NZSVH/6/@cdt71CdJwmDDEUhceOBCwPhF1oAccLBQMwssoGDTn7b01INDigtGXCWLsk/ZB0OIAPbIGRUqzmlOfZqHozseckkYilQNJ6xU97vsU52nmacOCSHe).
**Explanation:**
```
√∏           # Zip/transpose the (implicit) input-matrix; swapping rows/columns
 D          # Duplicate this
  ƒÄ         # Check for each value whether it's NOT 0 (0 if 0; 1 otherwise)
   P        # Take the product of each inner row
    √è       # Only leave the rows of the transposed matrix at the truthy (==1) positions
     √∏      # Zip/transpose the remaining rows back
      I     # Push the input-matrix again
       ƒÄP√è  # Do the same
            # (after which the filtered matrix is output implicitly as result)
```
[Answer]
# APL(NARS), 43 chars
```
{(c d)‚Üê1‚ç¥‚ç®¬®‚ç¥‚çµ‚ãÑc[‚Üë¬®k]‚Üêd[2‚àò‚äÉ¬®k‚Üê‚ç∏0=‚çµ]‚Üê0‚ãÑd/c‚åø‚çµ}
```
test:
```
  arr‚Üê3 3‚ç¥‚ç≥10‚ãÑarr1‚Üê6 5‚ç¥5 3 2 4 1 3 2 0 4 7 7 1 9 8 2 3 2 1 5 7 6 4 6 1 2 9 3 2 4 0
  g‚Üê{(c d)‚Üê1‚ç¥‚ç®¬®‚ç¥‚çµ‚ãÑc[‚Üë¬®k]‚Üêd[2‚àò‚äÉ¬®k‚Üê‚ç∏0=‚çµ]‚Üê0‚ãÑd/c‚åø‚çµ}
  g arr1
5 3 4
7 1 8
3 2 5
6 4 1
  g arr
1 2 3
4 5 6
7 8 9
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 8 bytes
```
fm‚ñº¬πTf‚ñºT
```
[Try it online!](https://tio.run/##yygtzv7/Py330bQ9h3aGpAGpkP///0dHm@oY6xjpmOgYxupEg1gGQLY5kG2uY6hjqWOhYwQVN9QxBYubAeXNgDyQuCVUr0FsLAA "Husk ‚Äì Try It Online")
### Explanation
```
fm‚ñº¬πTf‚ñºT
       T  Transpose the input
     f‚ñº   Filter out those rows (were columns) with a falsy minimum value
    T     Transpose back
f         Filter the rows based on
 m‚ñº¬π       the minimum values of the rows in the original input
```
[Answer]
# [Perl 5](https://www.perl.org/) `-MList::Util=product`, 88 bytes
```
sub{map{[@$_[grep{//;product(map{$$_[$']}@_)}0..$#$_]]}@_[grep{product@{$_[$_]}}0..$#_]}
```
[Try it online!](https://tio.run/##LY5tC4IwEMe/yrBRCvOpsgdF8APUy16NMaw0BNMxZxDDr966oW/u7n@/H8eJSraJwXVuhvGu36XQtMCcvmQldBhmQvbP8aFcCzDs8YZNBfemKAjwCnNm0ywvZqGtxdk0KzCYbCi/Dhx16l6uce1Wn7L1jEv3BJ0JghozguiWoIigA1SbdjMgaGsTaEeCTgQlC0sAWNP79UI1fTcY/5oEURxBvzSDStObatp8@cn43R8 "Perl 5 ‚Äì Try It Online")
]