Created
March 24, 2012 18:21
-
-
Save TimToady/2185853 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Test; | |
{ | |
my @grid = [ Bool.pick xx 5 ] xx 5; | |
my @neigh = [ ] xx 5; | |
for ^5 X ^5 -> $i, $j { | |
@neigh[$i][$j] = gather take-rw @grid[$i + .[0]][$j + .[1]] | |
if 0 <= $i + .[0] < 5 and 0 <= $j + .[1] < 5 | |
for [-1,-1],[+0,-1],[+1,-1], | |
[-1,+0],( ),[+1,+0], | |
[-1,+1],[+0,+1],[+1,+1]; | |
} | |
ok @grid[1][1] =:= @neigh[2][2][0], "Neighbor is same object as in grid"; | |
ok @neigh[1][1].elems == 8, "There are eight neighbors"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment