# New Ticket Created by  "Carl Mäsak" 
# Please include the string:  [perl #111962]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=111962 >


<TimToady> masak: two bug reports for the price of one; rakudo and
niecza both fail this test for different reasons:
https://gist.github.com/2185853
<TimToady> niecza because it has not take-rw (though take works
because it doesn't properly decontainerize)
<TimToady> rakudo because of the scoping issue in the list
comprehension (pretty much any refactoring of the loop and conditional
works)
<masak> TimToady: I'm wondering if you haven't just re-discovered
https://rt.perl.org/rt3/Ticket/Display.html?id=109322

TimToady's gist, reproduced here:

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";
}

Reply via email to