Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Re: expression formatting inside tables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg54638] Re: [mg54610] Re: [mg54591] expression formatting inside tables
  • From: "Owen, HL \(Hywel\)" <h.l.owen at dl.ac.uk>
  • Date: Fri, 25 Feb 2005 01:18:37 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

HoldAll turns off all the evaluation, not just the argument. You could just do it by brute force:

Table[{ToString[foo] <> "[" <> ToString[i] <> "]", foo[i]}, {i, 5}] // TableForm

which lets you use # instead of foo if you want to use this kind of expression in other situations. It ain't pretty, but it works.

Hywel

> -----Original Message-----
> From: Christoph Lhotka [mailto:lhotka at astro.univie.ac.at]
To: mathgroup at smc.vnet.net
> Sent: 24 February 2005 08:21
> To: mathgroup at smc.vnet.net
> Subject: [mg54638] [mg54610] Re: [mg54591] expression formatting inside tables 
> 
> 
> 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: finding roots of 1 + 6*x - 8*x^3
  • Next by Date: Re: Re: Mathematica 5 and Windows XP
  • Previous by thread: Re: expression formatting inside tables
  • Next by thread: Re: expression formatting inside tables