R, 19 bytes
\(m,x)which(m==x,T)
R has almost exactly the correct built-in for this.
R, 6464 59 bytes
Edit: -5 bytes thanks to pajonk
\(m,x,k=as.matrixk=t(t(expand.grid(lapply(dim(m),`:`,1)))))k[m[k]==x,]
Attempt This Online!Attempt This Online!
Roll-your-own solution without using which
.
expand.grid
is used to generate all possible sets of indices, which are then tested to see whether the element is equal to the searched-for x
. Unfortunately, expand.grid
outputs a "data.frame" (an R-specific matrix-like data type, but that isn't a matrix): pajonk's golf is to transpose twice (t(t(...))
) to convert into a matrix, saving 5 bytes compared to the more-conventional as.matrix(...)
...