# Distinguish three fraction forms (feature stronger than Hold)

This question can not be typed easily, using mathematica stackexchange interface.

So here is a GIF file :

My question is : Can we construct a function f whose output is

f /@ {7/3, 7/3, 7/3} (* all symbols become slash symbols after copy and paste *)

{"Slash form", "MiddleBar form", "Divide form"}


?

For this (=the existence of such f) to be possible, there must be something stronger than built in Hold.

• I think the question can be boiled down to "Why does Hold[7÷3] evaluate to Hold[7/3]? When does the conversion happen?" Interesting question. (+1) Mar 31, 2023 at 3:57

There is no f that could do this by itself because those forms are taken care of during parsing.

So by the time any evaluation rules associated with f take an effect there will be no trace of \[Divide] and only \ (or rather Times and Power).

Your input which is sent for evaluation is:

RowBox[{"{",
RowBox[{RowBox[{"7", "/", "3"}], ",",
FractionBox["7", "3"], ",",
RowBox[{"7", "\[Divide]", "3"}]}],
"}"}]


but we can exercise on a simpler string:

FullForm @ MakeExpression["f[7\[Divide]3]", StandardForm ]


HoldComplete[f[Times[7, Power[3, -1]]]]

You can intercept parsing but that's a modification to an 'environment' rather than evaluation alone so you'd need to provide a specific use case in order to get a suited solution.

Here is one example of such enhancement:

{7/3, 7/3, 7/3} (* original cell with 2D typesetting *)

InternalInheritedBlock[{MakeExpression}
, MakeExpression[RowBox[{n_, "/", d_}], fmt_] := HoldComplete["Slash form"]
; MakeExpression[RowBox[{n_, "\[Divide]", d_}], fmt_] := HoldComplete["Divide form"]
; MakeExpression[FractionBox[n_, d_], fmt_] := HoldComplete["MiddleBar form"]


{"Slash form", "MiddleBar form", "Divide form"}`