# Tag Info

1

The construction of custom operators with precedence is described in the Complex Patterns and Advanced Features Notation Package Tutorial. More general informations can be found in Precedence of Operators in Notations. The following operator definitions work for the examples given in the question. First loading the Notation Package: Needs["Notation"] ...

1

You can get the desired look using the Notation Package. << Notation Notation[ParsedBoxWrapper[RowBox[{"f", " ", RowBox[{"n_", "[", "x_", "]"}]}]] \[DoubleLongRightArrow] ParsedBoxWrapper[RowBox[{RowBox[{"f", "[", "n_", "]"}], "[", "x_", "]"}]]] which is displayed as when the Notation Palette is used to create the second part of the above ...

1

As others have said, this is a bad idea. However, if you only care about the appearance of f, then you could so something like this: f // ClearAll; intF = RowBox[ { RowBox[ { "f", "[", #1, "]" } ], "[", #2, "]" } ] &; dspF = RowBox[ { "f", #1, "[", #2, "]" } ] &; f /: MakeBoxes[ f[ n_ ][ x_ ], form_ ] := With[ { ns = ToString @ n, xs = ToString ...

12

Agree with other answers, this is a bad idea (why, precisely do you want to do this?), but in the spirit of encouraging unmaintainable write-once read-never code, here's my entry into the freak show: $NewSymbol = If[StringMatchQ[#, "f" ~~ NumberString], ToExpression[# <> "[x_]=x+" <> StringDrop[#, 1]]] &; Remove["f*"]; ... 4 In the interest of illustrating why what you've requested might be a bad idea, here's the simplest way I can think of to achieve your goal (there may be a better way): Do[(ToExpression["f" <> ToString[#]][x_] := x + #) &@ic, {ic, 1, 5}] ?f1 ?f5 It's much messier than the two characters you'd like to save and harder to index programatically, so ... 10 Just to be clear, I think this is a terrible idea but nevertheless, a question has been posed for which there is a simple answer: ClearAll@fn SetAttributes[fn, HoldAll] fn[h_[x_]] /; StringMatchQ[SymbolName@h, "f" ~~ DigitCharacter ..] := First@StringCases[SymbolName@h, "f" ~~ d : DigitCharacter .. :> x + ToExpression@d] ... 2 You can use TeXDelimited function from my TeXUtilities package, that was created precisely for this kind of tasks. Import["https://raw.githubusercontent.com/jkuczm/MathematicaTeXUtilities/master/NoInstall.m"] ClearAll[br] Format[br[x__], TeXForm] := TeXDelimited["(", x, ")", {"BodySeparator" -> "~", "DelimSeparator" -> ""}] br[1, 2, 3, 4]/br[2, ... 3 Here is a solution that automatically formats any instance of br[...] in the format that you want and that will be copy-and-pastable into LaTeX after converting to TexForm. Format[br[a__]] := DisplayForm@RowBox[Riffle[ToString /@ {a}, "\[ThinSpace]"]~Prepend~"("~Append~")"] \[ThinSpace] can be replaced alternatively by \[VeryThinSpace] or \[MediumSpace], ... 1 Another approach is to use RuleDelayed. br[2, 3, 4, 1] /. br[w_Integer, x_Integer, y_Integer, z_Integer] :> "(" <> Riffle[Map[ToString[#] &, {w, y, y, z}], " "] <> ")" The inner part produces a list of strings br[2, 3, 4, 1] /. br[w_Integer, x_Integer, y_Integer, z_Integer] :> Map[ToString[#] &, {w, y, y, z}] {"2", ... 2 StringReplace[ ToString@TeXForm@#, Shortest["\\text{br}(" ~~ s : __ ~~ ")"] :> "(" <> StringReplace[s, "," -> "~"] <> ")"] &@ (br[1, 2, 3, 4] br[2, 3, 4, 1] + br[2, 3, 4, 1]/br[1, 2, 3, 4]) "\frac{(1~2~3~4)}{(2~3~4~1)}+\frac{(2~3~4~1)}{(1~2~3~4)}" 2 StringReplace[StringDrop[ToString[TeXForm[br[1, 2, 3, 4]]], 9], "," -> " "]$\text{(1 2 3 4)}\$

Top 50 recent answers are included