Skip to content

Commit

Permalink
Make sub infix:<=~=> a multi
Browse files Browse the repository at this point in the history
- and make infix:<β‰…> an alias
- put actual logic on the ascii operator version, just like other operators
  • Loading branch information
lizmat committed Mar 1, 2018
1 parent 254f477 commit 5490bac
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/core/Numeric.pm
Expand Up @@ -285,9 +285,9 @@ proto sub infix:<==>(Mu $?, Mu $?) is pure {*}
multi sub infix:<==>($?) { Bool::True }
multi sub infix:<==>(\a, \b) { a.Numeric == b.Numeric }

proto sub infix:<β‰…>(Mu $?, Mu $?, *%) {*} # note, can't be pure due to dynvar
multi sub infix:<β‰…>($?) { Bool::True }
multi sub infix:<β‰…>(\a, \b, :$tolerance = $*TOLERANCE) {
proto sub infix:<=~=>(Mu $?, Mu $?, *%) {*} # note, can't be pure due to dynvar
multi sub infix:<=~=>($?) { Bool::True }
multi sub infix:<=~=>(\a, \b, :$tolerance = $*TOLERANCE) {
# If operands are non-0, scale the tolerance to the larger of the abs values.
# We test b first since $value β‰… 0 is the usual idiom and falsifies faster.
if b && a && $tolerance {
Expand All @@ -297,7 +297,8 @@ multi sub infix:<β‰…>(\a, \b, :$tolerance = $*TOLERANCE) {
abs(a.Num - b.Num) < $tolerance;
}
}
sub infix:<=~=>(|c) { infix:<β‰…>(|c) }
# U+2245 APPROXIMATELY EQUAL TO
my constant &infix:<β‰…> = &infix:<=~=>;

proto sub infix:<!=>(Mu $?, Mu $?) is pure {*}
multi sub infix:<!=>($?) { Bool::True }
Expand Down

0 comments on commit 5490bac

Please sign in to comment.