Print arrays from the middle out
MATL, 18 bytes
_G2$:iZ^t!|X>4#SY)
First input is s
, second is n
This works in current version (15.0.0) of the language.
Try it online!
Explanation
_ % take input s implicitly. Negate to obtain -s
G % push input s again
2$: % inclusive range from -s to s
i % take input n
Z^ % Cartesian power. Gives 2D array, with each result on a row
t! % duplicate and transpose
| % absolute value
X> % maximum of each column
4#S % sort and push the indices of the sorting
Y) % apply as row indices into the 2D array. Display implicitly
Jelly, 9 bytes
NRṗµAṀ€Ụị
No list subtraction was used in the making of this post. Try it online!
How it works
NRṗµAṀ€Ụị Main link. Arguments: s, n
N Negate; yield -s.
R Range; yield [-s, ..., s].
ṗ Cartesian power; push all vectors of length n of those elements.
µ Begin a new, monadic link. Argument: L (list of vectors)
A Compute the absolute values of all vector components.
Ṁ€ Get the maximum component of each vector.
Ụ Sort the indices of A according to the maximal absolute value of the
corresponding vector's components.
ị Retrieve the vectors of A at those indices.
Haskell, 61 60 bytes
n#s=[c|b<-[0..s],c<-mapM id$[-b..b]<$[1..n],any((b==).abs)c]
Usage example: 2#2
-> [[0,0],[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1],[-2,-2],[-2,-1],[-2,0],[-2,1],[-2,2],[-1,-2],[-1,2],[0,-2],[0,2],[1,-2],[1,2],[2,-2],[2,-1],[2,0],[2,1],[2,2]]
.
How it works:
b<-[0..s] -- loop b through 0 .. s
c<-mapM id$[-b..b]<$[1..n] -- loop c through all lists of length n
-- made out of the numbers -b .. b
-- ("[-b..b]<$[1..n]" is "replicate n [-b..b]";
-- "mapM id" is "sequence")
[c| ,any((b==).abs)c] -- keep c if it contains b or -b
Edit: @xnor pointed out that mapM id
is sequence
.