Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

List vs. array in Mathematica

355 views
Skip to first unread message

andymh...@gmail.com

unread,
Apr 12, 2014, 5:15:11 AM4/12/14
to
In mathematica, is an array simply a list of uniform depth? Both terms are used in the documentation, but I haven't run across an explicit explanation of why two terms are needed for the same construct. So I'm wondering if their relationship is.

Richard Fateman

unread,
Apr 13, 2014, 5:26:52 AM4/13/14
to
On 4/12/2014 2:15 AM, andymh...@gmail.com wrote:
> In mathematica, is an array simply a list of uniform depth?
No. An Array is a List. For example,

z= Array[f,4] returns{f[1],f[2],f[3],f[4]}
Head[z] returns List
z[[2]]={1,{2,3}}

is perfectly legal.

Note, there is a program Array[ ] which can be used to initially
construct Lists.
Both
> terms are used in the documentation, but I haven't run across an
> explicit explanation of why two terms are needed for the same
> construct.

They aren't. The term "array" is used in computer science and
conventional programming languages for a different data structure
with different storage requirements and different access efficiencies.

So I'm wondering if their relationship is.
>

Their relationship with respect to Mathematica is: the proprietors
of the program define arrays as lists, ignoring conventions in computer
science. One can speculate as to why.
See http://en.wikipedia.org/wiki/Hanlon%27s_razor

Murray Eisenberg

unread,
Apr 13, 2014, 5:27:12 AM4/13/14
to
The function Array does _not_ necessarily a list of uniform depth. For example:

f[n_] := Nest[List, x, n]
Array[f, 5]
(* {{x}, {{x}}, {{{x}}}, {{{{x}}}}, {{{{{x}}}}}} *)

However, the function ArrayQ does not return True for a "ragged" array but only she "all parts at a particular level must be lists of the same length.



On Apr 12, 2014, at 5:14 AM, andymh...@gmail.com wrote:

> In mathematica, is an array simply a list of uniform depth? Both terms are used in the documentation, but I haven't run across an explicit explanation of why two terms are needed for the same construct. So I'm wondering if their relationship is.
>

Murray Eisenberg mur...@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 240 246-7240 (H)
University of Massachusetts
710 North Pleasant Street
Amherst, MA 01003-9305







andymh...@gmail.com

unread,
Apr 14, 2014, 5:27:26 AM4/14/14
to
Richard, Murray,

Thank you for clarifying that Mathematica means a list when the word "array" is used, irrespective of its meaning outside of Mathematica.

Murray, I guess you can ignore the big long email I sent you. For some reason, I experience a delay in seeing postings to this group, so it looked as if you emailed me rather than replying on the group.

0 new messages