Tropical algebra overloading: Difference between revisions
m
→{{header|Raku}}: add constraint
Thundergnat (talk | contribs) m (→{{header|Raku}}: test relative precedence of ↑ and ⊕) |
Thundergnat (talk | contribs) m (→{{header|Raku}}: add constraint) |
||
Line 604:
No need to overload, define our own operators with whatever precedence level we want. Here we're setting precedence equivalent to existing operators.
<lang perl6>sub infix:<⊕> (Real $a, Real $b) is equiv(&[+])
sub infix:<⊗> (Real $a, Real $b) is equiv(&[×])
sub infix:<↑> (Real $a, Int $b where * ≥ 0) is equiv(&[**]) { [⊗] $a xx $b }
use Test;
|