MathGroup Archive 2005

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

Search the Archive

Re: expression formatting inside tables


Trevor Baca wrote:
> 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

Trevor,

Use replacement rules after you use HoldForm:

In[9]:= Table[{HoldForm[foo[a]]/.a->i,foo[i]},{i,5}]

Out[9]= {{foo[1],1},{foo[2],4},{foo[3],9},{foo[4],16},{foo[5],25}}

--
Igor Antonio
Wolfram Research, Inc.
http://www.wolfram.com

To email me personally, remove the dash.


  • Prev by Date: Re: statistics on a sphere
  • Next by Date: Why are permutations duplicated with LexicographicPermutations? How to avoid this?
  • Previous by thread: Re: expression formatting inside tables
  • Next by thread: Re: expression formatting inside tables