Skip to content

Commit

Permalink
minor series code refactor
Browse files Browse the repository at this point in the history
Signed-Off-By: Moritz Lenz <moritz@faui2k3.org>
  • Loading branch information
patrickas authored and moritz committed Jul 5, 2010
1 parent d9a5ac0 commit 1e7012c
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/core/operators.pm
Expand Up @@ -375,24 +375,15 @@ our multi sub infix:<...>(@lhs is copy, $rhs) {
when 1 {
$next = succ-or-pred(@lhs[0], $rhs)
}
when 2 {
my $diff = @lhs[1] - @lhs[0];
if $diff == 0 {
$next = succ-or-pred2(@lhs[0], @lhs[1], $rhs)
} else {
return Nil if is-on-the-wrong-side(@lhs[0] , @lhs[*-2] , @lhs[*-1] , $rhs);
$next = { $_ + $diff };
}
}
default {
my $diff = @lhs[*-1] - @lhs[*-2];
if $diff == 0 {
$next = succ-or-pred2(@lhs[*-2], @lhs[*-1], $rhs)
} elsif @lhs[*-2] - @lhs[*-3] == $diff {
} elsif @lhs.elems == 2 || @lhs[*-2] - @lhs[*-3] == $diff {
return Nil if is-on-the-wrong-side(@lhs[0] , @lhs[*-2] , @lhs[*-1] , $rhs);
$next = { $_ + $diff };
} elsif @lhs[*-2] / @lhs[*-3] == @lhs[*-1] / @lhs[*-2] {
$is-geometric-switching-sign = Bool::True if (@lhs[*-2] * @lhs[*-1] < 0);
$is-geometric-switching-sign = (@lhs[*-2] * @lhs[*-1] < 0);
return Nil if is-on-the-wrong-side(@lhs[0] , @lhs[*-2] , @lhs[*-1] , $rhs) && !$is-geometric-switching-sign;
$next = { $_ * (@lhs[*-2] / @lhs[*-3]) };
} else {
Expand Down

0 comments on commit 1e7012c

Please sign in to comment.