MathGroup Archive 2005

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

Search the Archive

Re: expression formatting inside tables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg54613] Re: [mg54591] expression formatting inside tables
  • From: "David Park" <djmp at earthlink.net>
  • Date: Thu, 24 Feb 2005 03:21:16 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

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.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/

From: Trevor Baca [mailto:trevorbaca at gmail.com]
To: mathgroup at smc.vnet.net

hi mathgroup folks,

let

  foo[x_] := x^2

then how to easily tableize the following?

  foo[1]   1
  foo[2]   4
  foo[3]   9
  foo[4]   16
  foo[5]   25

because neither

  Table[{HoldForm[foo[i]], foo[i]}, {i, 5}] // TableForm

nor

  Table[{foo[HoldForm[i]], foo[i]}, {i, 5}] // TableForm

did what i was expecting.

trevor




  • Prev by Date: Re: Labels on graphs
  • Next by Date: Re: pattern matching all list elements but last
  • Previous by thread: Re: expression formatting inside tables
  • Next by thread: Re: expression formatting inside tables