MathGroup Archive 2008

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

Search the Archive

Re: When is a List not a List?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90970] Re: When is a List not a List?
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Fri, 1 Aug 2008 03:00:01 -0400 (EDT)

On 7/31/08 at 2:56 AM, siegman at stanford.edu (AES) wrote:

>g[x_, n_] := x^n
>FullForm[Table[g[x, n], {n, 1, 2}]]
>FullForm[{g[x, 1], g[x, 2]}]
>Plot[{g[x, 1], g[x, 2]}, {x, 0, 1}, PlotStyle -> {Red, Blue}]
>Plot[Table[g[x, n], {n, 1, 2}], {x, 0, 1}, PlotStyle -> {Red, Blue}]

>The FullForm[]s are identical.

Right. Since FullForm displays the form of the evaluated
expression and each evaluates the same, the two should have the
same FullForm

>One Plot[] has red and blue curves; the other has two blue curves.

This too should be expected once you understand how Plot works.
Specifically, Plot has the attribute HoldAll which means the
first argument to Plot is not evaluated until after Plot has
substituted a numeric value for the variable (x in this case).

So, in the first case where there is an explicit list, Plot sees
a list of two functions and colors each according to your
PlotStyle specification. In the second case, Plot sees a single
function with multiple values for each x. Since Plot only sees a
single function, it plots it with the first PlotStyle only. You
can get the same result as the first Plot by using
Evaluate@Table so that Plot sees a list of two functions rather
than a single multi-valued function.


  • Prev by Date: Re: Constructing vector using table
  • Next by Date: Re: When is a List not a List?
  • Previous by thread: Re: Re: When is a List not a List?
  • Next by thread: Re: When is a List not a List?