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


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

Re: clearing a variable with a dummy subscript

Started byBob Hanlon <hanlonr357@gmail.com>
First post2012-05-19 09:45 +0000
Last post2012-05-19 09:45 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#10149 — Re: clearing a variable with a dummy subscript

FromBob Hanlon <hanlonr357@gmail.com>
Date2012-05-19 09:45 +0000
SubjectRe: clearing a variable with a dummy subscript
Message-ID<jp7q2v$qea$1@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@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
>

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web