Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve neighbours #30

Open
lauramcastro opened this issue Dec 9, 2021 · 1 comment
Open

Retrieve neighbours #30

lauramcastro opened this issue Dec 9, 2021 · 1 comment

Comments

@lauramcastro
Copy link

lauramcastro commented Dec 9, 2021

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).

@MLNW
Copy link

MLNW commented Dec 8, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants