Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
    
Postfix is a typesetting function and not the same as // in functionality –  rm -rf Mar 24 at 6:02
    
@Kuba that throws SetDelayed::write: "Tag Simplify in MakeBoxes[Simplify[expr_],StandardForm] is Protected" in my notebook. –  Daniel Mahler Mar 24 at 6:19
    
@DanielMahler You are right :) You can Unprotect but better not. –  Kuba Mar 24 at 6:21
    
@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. –  Daniel Mahler Mar 24 at 6:23
1  
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. –  Jacob Akkerboom Mar 24 at 10:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.