MathGroup Archive 1992

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

Search the Archive

Re: Iterator sequences

  • To: mathgroup at
  • Subject: Re: Iterator sequences
  • Date: 03 Oct 1992 20:41:20 -0700 (MST)

Hans Kunzle (hkunzle at asks:
>  Is there a way in Mathematica to generate a list of
>  iterators dynamically?
>  What I have in mind is something like
>    Sum[ Product[v[i]^j[i],{i,3}],Table[{j[i],nn[[i]]},{i,3}]]
>  where nn is a given list of integers.
>  This won't work since Table[..] is a list of lists, not
>  just a sequence. I tried to fool Mathematica into
>  accepting it by using
>    Sum[ Product[v[i]^j[i],{i,3}],
>         ToExpression[StringDrop[StringDrop[
>         ToString[Table[{j[i],nn[[i]]},{i,3}]],1],-1]] ]
>  but also get just an error message
A general method to capture the contents of a list without the enclosing
braces (i.e., as a sequence of items separated by commas) is to Apply Sequence
to it:
Sequence@@{x,y,z}  ------->  Sequence[x,y,z]
The first function that gets its hands on a Sequence object will strip off the
Sequence head, effectively splicing in a series of arguments separated by
commas. Thus you can use Sequence to "package" a series of arguments to a
Your example becomes:
The Evaluate is necessary to overcome the HoldAll attribute of Sum.
Todd Gayley
Department of Ecology and Evolutionary Biology
University of Arizona
tgayley at       -or-        tgayley at

  • Prev by Date: ListPlot3D
  • Next by Date: Erf or Hypergeometric1F1
  • Previous by thread: Iterator sequences
  • Next by thread: ListPlot3D