I was reading What is the distinction between DownValues, UpValues, SubValues, and OwnValues? and I started to be confused with the part "Upvalues" of the first answer.

Some of my confusion comes from the fact I don't really understand TagSetDelayed, I took a look at mathematica documentation but I'm more confused.

May I have a simple explanation of how it works with simple examples ?

The documentation take the example :

g /: f[g[x_]] := fg[x]
{f[g[2]], f[h[2]]}

{fg[2], f[h[2]]}

So, allright it means that when I call f[g[2]] it will be replaced by fg[2] But it seems to be more general as they do f[h[2]]. What happens in this case ? h is replacing g in the expression then we have f[h[2]].

Well I don't really get what is happening and how it can be usefull

  • 1
    $\begingroup$ This and this could be helpful $\endgroup$ – Lukas Lang Dec 30 '18 at 14:37
  • $\begingroup$ Is your question why wasn't h case converted? $\endgroup$ – Kuba Jan 2 '19 at 21:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.