1414 Integer1 ,
1515 Integer3 ,
1616 Integer310 ,
17+ Integer400 ,
1718 IntegerM1 ,
1819 Number ,
1920 Rational ,
4849 SymbolNull ,
4950 SymbolPower ,
5051 SymbolTimes ,
52+ SymbolTrue ,
5153)
5254from mathics .core .systemsymbols import (
5355 SymbolBlank ,
@@ -152,7 +154,7 @@ class Divide(BinaryOperator):
152154 default_formats = False
153155
154156 formats = {
155- (( "InputForm" , "OutputForm" ) , "Divide[x_, y_]" ): (
157+ ("InputForm" , "Divide[x_, y_]" ): (
156158 'Infix[{HoldForm[x], HoldForm[y]}, "/", 400, Left]'
157159 ),
158160 }
@@ -166,9 +168,26 @@ class Divide(BinaryOperator):
166168 "FractionBox[MakeBoxes[x, f], MakeBoxes[y, f]]"
167169 ),
168170 }
169-
170171 summary_text = "divide"
171172
173+ def format_outputform (self , x , y , evaluation ):
174+ "OutputForm: Divide[x_, y_]"
175+ use_2d = (
176+ evaluation .definitions .get_ownvalues ("System`$Use2DOutputForm" )[0 ].replace
177+ is SymbolTrue
178+ )
179+ if not use_2d :
180+ return Expression (
181+ SymbolInfix ,
182+ ListExpression (
183+ Expression (SymbolHoldForm , x ), Expression (SymbolHoldForm , y )
184+ ),
185+ String ("/" ),
186+ Integer400 ,
187+ SymbolLeft ,
188+ )
189+ return None
190+
172191
173192class Minus (PrefixOperator ):
174193 """
@@ -406,10 +425,21 @@ class Power(BinaryOperator, MPMathFunction):
406425 Expression (SymbolPattern , Symbol ("x" ), Expression (SymbolBlank )),
407426 RationalOneHalf ,
408427 ): "HoldForm[Sqrt[x]]" ,
409- (("InputForm" , "OutputForm" ), "x_ ^ y_" ): (
428+ (("InputForm" ,), "x_ ^ y_" ): (
410429 'Infix[{HoldForm[x], HoldForm[y]}, "^", 590, Right]'
411430 ),
412- ("" , "x_ ^ y_" ): (
431+ (("OutputForm" ,), "x_ ^ y_" ): (
432+ "If[$Use2DOutputForm, "
433+ "Superscript[HoldForm[x], HoldForm[y]], "
434+ 'Infix[{HoldForm[x], HoldForm[y]}, "^", 590, Right]]'
435+ ),
436+ (
437+ (
438+ "StandardForm" ,
439+ "TraditionalForm" ,
440+ ),
441+ "x_ ^ y_" ,
442+ ): (
413443 "PrecedenceForm[Superscript[PrecedenceForm[HoldForm[x], 590],"
414444 " HoldForm[y]], 590]"
415445 ),
0 commit comments