Tropical algebra overloading: Difference between revisions

Add Factor
m (→‎{{header|R}}: document)
(Add Factor)
Line 30:
:;*[[https://en.wikipedia.org/wiki/Operator_overloading Operator overloading]]
 
 
=={{header|Factor}}==
{{works with|Factor|0.99 2021-06-02}}
<lang factor>USING: io kernel math math.order present prettyprint sequences ;
 
ALIAS: t+ max
ALIAS: t* +
ALIAS: t^ *
 
: show ( quot -- )
dup present rest but-last "-> " append write call . ; inline
 
{
[ 2 -2 t* ]
[ -0.001 -1/0. t+ ]
[ 0 -1/0. t* ]
[ 1.5 -1 t+ ]
[ -0.5 0 t* ]
[ 5 7 t^ ]
[ 8 7 t+ 5 t* ]
[ 5 8 t* 5 7 t* t+ ]
[ 8 7 t+ 5 t* 5 8 t* 5 7 t* t+ = ]
} [ show ] each</lang>
{{out}}
<pre>
2 -2 t* -> 0
-0.001 -1/0. t+ -> -0.001
0 -1/0. t* -> -1/0.
1.5 -1 t+ -> 1.5
-0.5 0 t* -> -0.5
5 7 t^ -> 35
8 7 t+ 5 t* -> 13
5 8 t* 5 7 t* t+ -> 13
8 7 t+ 5 t* 5 8 t* 5 7 t* t+ = -> t
</pre>
 
=={{header|Julia}}==
1,808

edits