Output the anti-clockwise inward spiral of a 2D array
R, 54 bytes

Several bytes saved by @Giuseppe and @J.Doe.



f=function(m)if(ncol(m))c(m[,1],f(t(m[nrow(m):1,-1])))


Try it online!

Recursively strip off the first column and row-reverse/transpose (making the bottom row the new first column) the rest of the matrix until you end up with only one column. Ungolfed "traditional" version:

f &lt;- function(m) {
 if(ncol(m) == 1) {
    m
  } else {
    c(m[,1], f(t(m[nrow(m):1,-1])))
  }
}


It was pointed out that ncol(m) could be golfed to sum(m) to save another byte because we are allowed to assume positive integer matrix values. But I'll leave it like this since it works for all matrices (even matrices of strings!)