Skip to content

Commit

Permalink
switch to strict numification by default
Browse files Browse the repository at this point in the history
also make non-numeric sequences a bit more robust
  • Loading branch information
moritz committed May 18, 2012
1 parent c78c85c commit 09e678f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/core/Str.pm
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ my class Str does Stringy {
$str;
}

multi method Numeric(Str:D: :$strict) {
multi method Numeric(Str:D: :$strict = True) {
return 0 if self eq '';
return nqp::p6box_n(pir::set__Ns('NaN')) if self eq 'NaN';
my str $str = nqp::unbox_s(self);
my int $eos = nqp::chars($str);
Expand Down
5 changes: 4 additions & 1 deletion src/core/operators.pm
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ multi infix:<but>(Mu:U \$obj, @roles) {
sub SEQUENCE($left, $right, :$exclude_end) {
my @right := $right.flat;
my $endpoint = @right.shift;
my $infinite = $endpoint ~~ Whatever;
my $infinite = $endpoint ~~ Whatever || $endpoint === $Inf;
$endpoint = Bool::False if $infinite;
my $tail := ().list;

Expand All @@ -110,6 +110,9 @@ sub SEQUENCE($left, $right, :$exclude_end) {
my $b = $tail[1];
my $c = $tail[2];
if $code.defined { }
elsif $a !~~ Numeric {
$code = succpred($tail[*-1] cmp $endpoint);
}
elsif $tail.elems == 3 {
my $ab = $b - $a;
if $ab == $c - $b {
Expand Down

0 comments on commit 09e678f

Please sign in to comment.