MathGroup Archive 2005

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

Search the Archive

Re: expression formatting inside tables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg54610] Re: [mg54591] expression formatting inside tables
  • From: "Christoph Lhotka" <lhotka at astro.univie.ac.at>
  • Date: Thu, 24 Feb 2005 03:21:13 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

On Wed, 23 Feb 2005 03:12:53 -0500 (EST)
 "Trevor Baca" <trevorbaca at gmail.com> 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
> 

Hi, I think, this is the easiest way, if you need such output:

In[..]:= Table[{"foo"[x], foo[x]}, {x, 1, 5}] // TableForm
Out[..]/TableForm:=
          foo[1] 1
          foo[2] 4
          foo[3] 9
          foo[4] 16
          foo[5] 25

But be sure, that this is something like a trick, because "foo"[x] and foo[x]
are two different things...

In[..]:=FullForm[%]
Out[..]:=List[List["foo"[1], 1], List["foo"[2], 4], List["foo"[3], 9], 
  List["foo"[4], 16], List["foo"[5], 25]]

-- Christoph Lhotka --
University of Vienna
Institute for Astronomy
Tuerkenschanzstr. 17 
1180 Vienna, Austria
fon. +43.1.4277.518.41
mail. lhotka at astro.univie.ac.at


  • Prev by Date: Re: Mathematica 5 and Windows XP
  • Next by Date: Bounds for Trig expression
  • Previous by thread: Re: expression formatting inside tables
  • Next by thread: Re: Re: expression formatting inside tables