Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #10149

Re: clearing a variable with a dummy subscript

From Bob Hanlon <hanlonr357@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: clearing a variable with a dummy subscript
Date 2012-05-19 09:45 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jp7q2v$qea$1@smc.vnet.net> (permalink)
References <201205180925.FAA17125@smc.vnet.net>

Show all headers | View raw


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@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
>

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: clearing a variable with a dummy subscript Bob Hanlon <hanlonr357@gmail.com> - 2012-05-19 09:45 +0000

csiph-web