Re: subscripts in function definitions

*To*: mathgroup at smc.vnet.net*Subject*: [mg105048] Re: [mg105028] subscripts in function definitions*From*: DrMajorBob <btreat1 at austin.rr.com>*Date*: Thu, 19 Nov 2009 05:22:45 -0500 (EST)*References*: <200911181159.GAA04314@smc.vnet.net>*Reply-to*: drmajorbob at yahoo.com

I never use subscripts, but if you really want to: x = Array[Prime, 10]; f[Subscript[x, L_]] := x[[L]] Array[f[Subscript[x, #]] &, 10] Table[f[Subscript[x, i]], {i, 1, 10, 2}] {2, 3, 5, 7, 11, 13, 17, 19, 23, 29} {2, 5, 11, 17, 23} Bobby On Wed, 18 Nov 2009 05:59:33 -0600, Murat Tasan <mmuurr at gmail.com> wrote: > hi, folks - i'm not very savvy with Mathematica, so i apologize in > advance if this is a silly question, but: > > i'd like to define a function, say f, that takes the symbol Subscript > [x,L]_. > > it's hard to replicate what i'm typing here, without the ability to > subscript, but basically i want an x with a subscript of L as the > entire variable. something like xL (only with the L sub-scripted). > > when i try to enter this as a pattern in the function definition by > adding the trailing underscore, it attaches only to the L (in the > subscript), not to the whole x_L variable (thus making the pattern > only match "L"). if i move out of the subscript box and try to add > the trailing underscore at the "x" level, it becomes detached from the > whole expression. so i tried creating the pattern explicitly, as so: > > f[Subscript[x,L]_] := myfun > > but also in this case the trailing underscore becomes non-associated > with the Subscript expression. > > is there any way i can make x with a subscript of L the entire pattern > for a variable? > > (hopefully this made some sense... hard to make clear what i'm > searching for in plain text!) > -- DrMajorBob at yahoo.com

**References**:**subscripts in function definitions***From:*Murat Tasan <mmuurr@gmail.com>