MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: clearing a variable with a dummy subscript

  • To: mathgroup at smc.vnet.net
  • Subject: [mg126557] Re: clearing a variable with a dummy subscript
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Sat, 19 May 2012 05:43:30 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201205180925.FAA17125@smc.vnet.net>

Subscript[u, k_] := k

Subscript[u, 2]

2

This assignment is associated with Subscript rather than with u

You would need to clear Subscript.

Clear[Subscript]

Subscript[u, 2]

Subscript[u, 2]

However, if you had made multiple assignments with Subscript this
would clear all of them rather than just u

To associate the assignment with just u, use an upvalue (see help for
UpValues, UpSet, UpSetDelayed)

u /: Subscript[u, k_] := k

Subscript[u, 2]

2

Now Clear will work as you intended

Clear[u];

Subscript[u, 2]

Subscript[u, 2]


Bob Hanlon


On Fri, May 18, 2012 at 5:25 AM, Andre Hautot <ahautot at ulg.ac.be> wrote:
>
> Hi !
> Here is something very simple I don't understand :
>
> f[x_] := x; f[2]    (*A function*)
>  2
>
> Clear[f]; f[2]       (*The same perfectly cleared as expected*)
> f[2]
>
>
> Subscript[u, k_] := k; Subscript[u, 2]        (*u with subscrip=
t k_
> entered via the palette*)
>  2
>
> Clear[u]; Subscript[u, 2]          (*I found no way to clear u;=
 a
> suggestion ?)
> 2
>
> Thanks in advance,
>
> ahautot
>



  • Prev by Date: Re: Is Mathematica v8 slower than v7 ?
  • Next by Date: Re: InverseFunction returning working function or just a symbol
  • Previous by thread: clearing a variable with a dummy subscript
  • Next by thread: Re: clearing a variable with a dummy subscript