I need to generate a coordinate set in Erlang. For one coordinate say (x, y) I need to generate (x-1, y-1), (x-1, y), (x-1, y + 1), (x, y-1), (x , y + 1), (x + 1, y-1), (x + 1, y), (x + 1, y + 1). Basically, all surrounding coordinates EXCEPT the middle coordinate (x, y). To generate all nine coordinates, I am doing this currently:
[{X,Y} || X<-lists:seq(X-1,X+1), Y<-lists:seq(Y-1,Y+1)]
But this generates all the values, including (X, Y). How to exclude (X, Y) from a list using filters in list comprehension?
erlang list-comprehension
Erjab
source share