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
The function in live_neighbor_count of Game of life should iterate delta_* from [-1, 0, 1] instead of from [self.height - 1, 0, 1] and [self.width - 1, 0, 1].
The text was updated successfully, but these errors were encountered:
tinoism
added a commit
to tinoism/book
that referenced
this issue
Jul 3, 2019
Just realized that it wouldn't compile... Although the intuition about having the negative index is correct, in rust we annotate the negative indices by adding the length of the array. For instance, "negative indexes like -1 and -2 get added to the length of the slice to become real indices, like len - 1 and len - 2" as indicated in this issue.
The function in
live_neighbor_count
of Game of life should iteratedelta_*
from[-1, 0, 1]
instead of from[self.height - 1, 0, 1]
and[self.width - 1, 0, 1]
.The text was updated successfully, but these errors were encountered: