Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Sundry Questions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61094] Re: Sundry Questions
  • From: "Scout" <mathem at tica.org>
  • Date: Mon, 10 Oct 2005 02:39:55 -0400 (EDT)
  • References: <diabu7$ikb$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"Matt" <anonmous69 at netscape.net>
>
> Question:  When dealing with subscripts, how do I do pattern matching?
> e.g. I have a list of rules such as solsList = {x1[t]->something,
> x2[t]->somethingElse} where the '1' and the '2' are actually
> subscripts, I can use x1[t] /. solsList to get back x1 or x2[t] /.
> solsList to get back x2 (where, again, '1' and '2' are subscripts).
> However, if I try to use Subscript[x,_] as the pattern, it never finds
> anything.
>

Hi Matt,
I've tried in Math 5.2 what you're asking for.
I get no problem:

In[1]:= sol={Subscript[x, a_]®a x };
            \!\(\(sol2 = {x\_a_ \[Rule] x^a};\)\)

In[2]:= \!\(x\_5 /. sol\)
Out[2]= 5 x

In[3]:= Subscript[x,5]/.sol
Out[3]= 5 x

In[4]:= \!\(x\_5 /. sol2\)
Out[4]= \!\(x\^5\)

In[5]:= Subscript[x,5]/.sol2
Out[5]= \!\(x\^5\)

    ~Scout~ 


  • Prev by Date: Re: leaveing out empty ticks that have no data
  • Next by Date: Inadvertant introduction of Global` symbols from packages
  • Previous by thread: Sundry Questions
  • Next by thread: Re: Sundry Questions