Jump to content

Tropical algebra overloading: Difference between revisions

m
→‎{{header|Raku}}: add constraint
m (→‎{{header|Raku}}: test relative precedence of ↑ and ⊕)
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(&[+]) { $a max $b }
sub infix:<⊗> (Real $a, Real $b) is equiv(&[×]) { $a + $b }
sub infix:<↑> (Real $a, Int $b where * ≥ 0) is equiv(&[**]) { [⊗] $a xx $b }
use Test;
10,333

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.