Tropical algebra overloading: Difference between revisions

Content added Content deleted
(Add Factor)
m (→‎{{header|Factor}}: change names, tweak output)
Line 35: Line 35:
<lang factor>USING: io kernel math math.order present prettyprint sequences ;
<lang factor>USING: io kernel math math.order present prettyprint sequences ;


ALIAS: t+ max
ALIAS: max
ALIAS: t* +
ALIAS: +
ALIAS: t^ *
ALIAS: *


: show ( quot -- )
: show ( quot -- )
dup present rest but-last "-> " append write call . ; inline
dup present rest but-last " " append write call . ; inline


{
{
[ 2 -2 t* ]
[ 2 -2 ]
[ -0.001 -1/0. t+ ]
[ -0.001 -1/0. ]
[ 0 -1/0. t* ]
[ 0 -1/0. ]
[ 1.5 -1 t+ ]
[ 1.5 -1 ]
[ -0.5 0 t* ]
[ -0.5 0 ]
[ 5 7 t^ ]
[ 5 7 ]
[ 8 7 t+ 5 t* ]
[ 8 7 5 ]
[ 5 8 t* 5 7 t* t+ ]
[ 5 8 5 7 ]
[ 8 7 t+ 5 t* 5 8 t* 5 7 t* t+ = ]
[ 8 7 5 5 8 5 7 = ]
} [ show ] each</lang>
} [ show ] each</lang>
{{out}}
{{out}}
<pre>
<pre>
2 -2 t* -> 0
2 -2 0
-0.001 -1/0. t+ -> -0.001
-0.001 -1/0. -0.001
0 -1/0. t* -> -1/0.
0 -1/0. -1/0.
1.5 -1 t+ -> 1.5
1.5 -1 1.5
-0.5 0 t* -> -0.5
-0.5 0 -0.5
5 7 t^ -> 35
5 7 35
8 7 t+ 5 t* -> 13
8 7 5 13
5 8 t* 5 7 t* t+ -> 13
5 8 5 7 13
8 7 t+ 5 t* 5 8 t* 5 7 t* t+ = -> t
8 7 5 5 8 5 7 = t
</pre>
</pre>