1

I would like to define a rule that suppress any arguments of a function for visibility. I tried:

rule = f_[x__] -> f

While this works well with individual terms (including derivatives of expressions), products of functions don't work, such as

f[x] R[r] /. rule

which outputs "Times" for some reason?

Patrick.B
  • 1,399
  • 5
  • 11

2 Answers2

5

It's because Head[f[x] R[r]] is Times. You should rewrite your rule as

rule = f_[x__] /; ! MatchQ[f, Times] :> f

Now

f[x] R[r] /. rule    
f R

I would like to define a rule that suppress any arguments of a function for visibility.

I think my shortInputForm function can be of interest for you. It doesn't completely suppress arguments but rather shortens long lists of numbers for readability.

Alexey Popkov
  • 61,809
  • 7
  • 149
  • 368
3

I think you can create a wrapper that modifies the box generation code so that it never generates brackets:

MakeBoxes[SuppressBracketArguments[expr_], StandardForm] ^:= ReplaceAll[
    MakeBoxes[expr,StandardForm],
    RowBox[{h_, "[",___,"]"}]->h
]

A couple examples:

f[g[x]] //SuppressBracketArguments
f[x] g[y] //SuppressBracketArguments

f

f g

Carl Woll
  • 130,679
  • 6
  • 243
  • 355