MathGroup Archive 2005

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

Search the Archive

Re: expression formatting inside tables

In article <cvk3vk$d93$1 at>,
 "David Park" <djmp at> wrote:

> Trevor,
> foo[x_] := x^2
> Table[{HoldForm[foo[j]], foo[j]} /. j -> i, {i, 5}] // TableForm
> If you look up the Table Help and then follow the link to Section A.4.2 on
> evaluation of iteration functions you will see why this is necessary. Table
> essentially creates a Block environment, sets i to an iterator value and
> then evaluates the argument. But HoldForm[foo[i]] does not evaluate so it
> does not get changed.
> However, you can substitute into held expressions using Rules.

I think a more elegant solution is

  foo[x_] := x^2

  p[i_] = {HoldForm[foo[i]], foo[i]}

  Table[p[i], {i, 5}] // TableForm


Paul Abbott                                   Phone: +61 8 6488 2734
School of Physics, M013                         Fax: +61 8 6488 1014
The University of Western Australia      (CRICOS Provider No 00126G)         
35 Stirling Highway
Crawley WA 6009                      mailto:paul at 

  • Prev by Date: Mathematica batch file
  • Next by Date: Re: Computing Complex Series Solution using Mathematica
  • Previous by thread: Re: Re: expression formatting inside tables
  • Next by thread: Re: expression formatting inside tables