MathGroup Archive 2011

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

Search the Archive

Re: Plot in a Module

  • To: mathgroup at smc.vnet.net
  • Subject: [mg123899] Re: Plot in a Module
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Thu, 29 Dec 2011 02:52:27 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

On 12/28/11 at 5:16 AM, sam.takoy at yahoo.com (Sam Takoy) wrote:


>How does one use the Plot command inside a Module? I find that if
>one places a semi-colon after the command, then the output is
>suppressed. But it also seems illegal to skip the semi-colon? So how
>does one do it?

No, it is not illegal to skip a semicolon. Either of the
following constructs will create a plot

Module[{x = 2},
  Plot[y^2, {y, 0, x}]]

or

Module[{x, p},
  x = 2;
  p = Plot[y^2, {y, 0, x}];
  Sqrt[x];
  p]

All a semicolon does is create a compound expression. The last
element of a compound expression determines what is displayed.
When you do say

x=2;

You actually create the compound expression x = 2;Null. Since
the last element is Null which does nothing, nothing is displayed.




  • Prev by Date: Undefined under GNU / Linux
  • Next by Date: Cellular Automaton Syntax
  • Previous by thread: Re: Plot in a Module
  • Next by thread: Re: Why does Manipulate leak global symbols? (Potential bug here?)