Commits

Shlomi Fish committed c0ba36c

Extract _x_in_range and _y_in_range.

  • Participants
  • Parent commits d9c310d

Comments (0)

Files changed (2)

File abc-path/Games-ABC_Path-Solver/lib/Games/ABC_Path/Solver/Base.pm

     return (0 .. $LEN_LIM);
 }
 
+sub _x_in_range
+{
+    my ($self, $x) = @_;
+
+    return ($x >= 0 and $x < $LEN);
+}
+
+sub _y_in_range
+{
+    my ($self, $y) = @_;
+
+    return $self->_x_in_range($y);
+}
+
 =head1 AUTHOR
 
 Shlomi Fish, C<< <shlomif at cpan.org> >>

File abc-path/Games-ABC_Path-Solver/lib/Games/ABC_Path/Solver/Board.pm

         {
             foreach my $coords
             (
-                grep { $_->[0] >= 0 and $_->[0] < $LEN and $_->[1] >= 0 and
-                $_->[1] < $LEN }
+                grep {
+                    $self->_x_in_range($_->[0]) and $self->_y_in_range($_->[1])
+                }
                 map { [$true->[0] + $_->[0], $true->[1] + $_->[1]] }
                 map { my $d = $_; map { [$_, $d] } (-1 .. 1) }
                 (-1 .. 1)