Write a function that returns an iterable object of all valid points 4-directionally adjacent to (x, y)
Python 2, 66 bytes



lambda m,n,x,y:[(x-1,y),(x+1,y)][~x:m-x]+[(x,y-1),(x,y+1)][~y:n-y]


Try it online!

Lists the four neighbors, then uses list slicing to remove those that are out-of-bounds.



Python 2, 71 bytes



lambda m,n,x,y:[(k/n,k%n)for k in range(m*n)if(k/n-x)**2+(k%n-y)**2==1]


Try it online!

Instead of checking which of the four neighbors are in-bounds, we do it the slower way of checking all in-bounds points for those that are neighbors, that is have Euclidian distance exactly 1 from (x,y). We also use the classic div-mod trick to iterate over a grid, saving the need to write two loops like for i in range(m)for j in range(n).

I tried using complex arithmetic to write the distance condition, but it turned out longer to write abs((k/n-x)*1j+k%n-y)==1.



Python 2, 70 bytes



lambda m,n,x,y:[(x+t/3,y+t%3-1)for t in-2,0,2,4if m&gt;x+t/3&gt;=0&lt;y+t%3&lt;=n]


Try it online!