You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using Matrex in the context of AoC for the second year now, and it is not the first time I am confronted with the need to get the neighbours of a given position in the matrix.
That is, given a valid position {x,y}, calculating the list of [{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}] (or a subset of this, including only valid points inside the bounds of the matrix, of course).
This would be very much appreciated! I'm currently using matrex for the same purpose. Sadly it seems that this excellent library does not get a lot of love in general any more.
I am using Matrex in the context of AoC for the second year now, and it is not the first time I am confronted with the need to get the neighbours of a given position in the matrix.
That is, given a valid position
{x,y}
, calculating the list of [{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}] (or a subset of this, including only valid points inside the bounds of the matrix, of course).Would a PR implementing
Matrex.neighbours/3
as@spec neighbours(Matrix.t(), non_neg_integer(), non_neg_integer())
something that this project would be interested in? If so, I offer to implement such PR.
An alternative would be
Matrex.neighbours/4
,@spec neighbours(Matrix.t(), non_neg_integer(), non_neg_integer(), boolean())
with an optional argument (default true) to consider the diagonals (or not).
The text was updated successfully, but these errors were encountered: