MathGroup Archive 2008

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

Search the Archive

Re: Newbie question: Which is more versatile, Table[] or Array[]?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg94150] Re: Newbie question: Which is more versatile, Table[] or Array[]?
  • From: magma <maderri2 at gmail.com>
  • Date: Fri, 5 Dec 2008 07:05:50 -0500 (EST)
  • References: <ghb034$oii$1@smc.vnet.net>

On Dec 5, 11:34 am, stpatryck <stpatr... at gmail.com> wrote:
> I'm reading the Schaum's Outline for Mathematica and am in the chapter
> concerning list manipulation.  So far, the only difference I can tell
> between the Array[] and Table[] commands is that with Table, you use
> an expression as the first parameter/argument and with Array, you use
> a function.  The other parameters, of course, are tailored differently
> because they support the first parameter i.e. expression or function.
>
> Anyone know of any significant difference between these two commands
> other than syntax?  Please feel free to e-mail me at
> stpatr... at gmail.com.
>
> Thanks,
> Patrick

There is of course a certain overlap between Array and Table, but
table is more general and powerful.
This means that anything you can do with Array can be done with Table
too, but not vice versa (in an easy way).
Strtictly speaking I think the 2 commands are indeed equivalent, but
in some cases Table is clearly the best choice.


For example look at the documentation for Table/relations to other
functions

Array[#1^#2 &, {3, 4}]

can easily be translated into

Table[x^y, {x, 3}, {y, 4}]

But Array has a limitation: the index (or indices) are always
integers, while with Table the index can step through a list of
symbols as in

Table[f[c], {c, {red, green, blue}}]

This could be done with Array and some helper functions too, but not
easily.

When you have indices that take integer values, they are essentially
equivalent.

hth


  • Prev by Date: Re: Newbie question: Which is more versatile, Table[] or Array[]?
  • Next by Date: Re: Rearranging expressions in a user-defined form
  • Previous by thread: Re: Newbie question: Which is more versatile, Table[] or Array[]?
  • Next by thread: Re: Re: Newbie question: Which is more versatile, Table[] or Array[]?