Re: expression formatting inside tables

• To: mathgroup at smc.vnet.net
• Subject: [mg54682] Re: expression formatting inside tables
• From: Paul Abbott <paul at physics.uwa.edu.au>
• Date: Sun, 27 Feb 2005 01:29:06 -0500 (EST)
• Organization: The University of Western Australia
• References: <cvk3vk\$d93\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```In article <cvk3vk\$d93\$1 at smc.vnet.net>,
"David Park" <djmp at earthlink.net> 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

Cheers,
Paul

--
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 physics.uwa.edu.au
AUSTRALIA                            http://physics.uwa.edu.au/~paul

```

• 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