Skip to content

Commit c978843

Browse files
authored
Merge pull request #1434 from drgrice1/matrix-check-num-first
Check for a numeric value before using numerically.
2 parents 7fb94d9 + 0eb6396 commit c978843

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

lib/Value/Matrix.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,7 @@ sub removeRow {
15041504
Value::Error("removeRow cannot be used on a Matrix of degree 1") if $degree == 1;
15051505
my @indices = map { [ 1 .. $_ ] } @dim;
15061506
Value::Error("Can only remove rows 1 through $indices[0][-1]")
1507-
unless $r >= 1 && $r <= $indices[0][-1] && $r =~ /^\d+$/;
1507+
unless $r =~ /^\d+$/ && $r >= 1 && $r <= $indices[0][-1];
15081508
return $self->subMatrix([ grep { $_ != $r } @{ $indices[0] } ], @indices[ 1 .. $#indices ]);
15091509
}
15101510

@@ -1531,7 +1531,7 @@ sub removeColumn {
15311531
Value::Error("removeColumn cannot be used on a Matrix of degree 1") if $degree == 1;
15321532
my @indices = map { [ 1 .. $_ ] } @dim;
15331533
Value::Error("Can only remove columns 1 through $indices[1][-1]")
1534-
unless $r >= 1 && $r <= $indices[1][-1] && $r =~ /^\d+$/;
1534+
unless $r =~ /^\d+$/ && $r >= 1 && $r <= $indices[1][-1];
15351535
return $self->subMatrix($indices[0], [ grep { $_ != $r } @{ $indices[1] } ], @indices[ 2 .. $#indices ]);
15361536
}
15371537

0 commit comments

Comments
 (0)