It seems to be a fairly common convention to write certain 'meta' functions in postfix form like

f[x] // Simplify

to keep the the mathematical content at the front separate from the various directives. However converting expressions to StandardForm or InputForm converts everything to prefix. Is there a way to get StandardForm to use this convention or alternatively is there a form like StandardForm, but that uses this convention. I find myself often switching betweenStandardForm and InputForm while editing since I prefer to just edit textually using InputForm and then convert to StandardForm for display, but this makes it impossible to use the above convention.

Reading the documentation I came across Format which seems one possible way to do this, but the following does not work:

Format[Simplify[x_], StandardForm] := Postfix[Simplify[x_]]

Apparently Simplify gets evaluated out before this rule is set up. I tried using Hold and Unevaluated to fix this without luck. This approach would also have the downside of having to define this rule for every function separately and I also do not yet know how I would set up such rules as a default for all my notebooks. So maybe there is a better way.

  • $\begingroup$ Postfix is a typesetting function and not the same as // in functionality $\endgroup$
    – rm -rf
    Mar 24, 2014 at 6:02
  • $\begingroup$ @Kuba that throws SetDelayed::write: "Tag Simplify in MakeBoxes[Simplify[expr_],StandardForm] is Protected" in my notebook. $\endgroup$ Mar 24, 2014 at 6:19
  • $\begingroup$ @DanielMahler You are right :) You can Unprotect but better not. $\endgroup$
    – Kuba
    Mar 24, 2014 at 6:21
  • $\begingroup$ @rm-rf I understand. I want Simplify to always appear in postfix position. I do not care that much if the actual expression gets rearranged or if it is just rendered that way, which is what I understand Format rules do. $\endgroup$ Mar 24, 2014 at 6:23
  • 1
    $\begingroup$ I think it is impossible to change definitions of how InputForm gets formatted. Furthermore InputForm works on expressions rather than boxes, so that making a solution based on whether you typed postfix vs prefix seems to be impossible, as the information of whether you typed prefix or postfix is lost when the boxes get converted by MakeExpression. $\endgroup$ Mar 24, 2014 at 10:14


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.