Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2009

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

Search the Archive

Re: subscripts in function definitions

  • To: mathgroup at
  • Subject: [mg105048] Re: [mg105028] subscripts in function definitions
  • From: DrMajorBob <btreat1 at>
  • Date: Thu, 19 Nov 2009 05:22:45 -0500 (EST)
  • References: <>
  • Reply-to: drmajorbob at

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}


On Wed, 18 Nov 2009 05:59:33 -0600, Murat Tasan <mmuurr at> 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

  • Prev by Date: Re: How to instruct Math to take a certain (e.g. real)
  • Next by Date: Re: How to instruct Math to take a certain (e.g. real) type of
  • Previous by thread: subscripts in function definitions
  • Next by thread: Re: subscripts in function definitions