Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

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

Search the Archive

Re: ListLinePlot[] inside a loop

  • To: mathgroup at smc.vnet.net
  • Subject: [mg82392] Re: ListLinePlot[] inside a loop
  • From: "Szabolcs HorvÃt" <szhorvat at gmail.com>
  • Date: Fri, 19 Oct 2007 04:58:06 -0400 (EDT)
  • References: <ff789h$nrs$1@smc.vnet.net> <47176E01.1010906@gmail.com>

On 10/18/07, Luiz Melo <luiz.melo at polymtl.ca> wrote:
>
> Hi Szabolcs, thanks for the answer.
> By the way, why we should avoid Do,For,While in mathematica?
> The example I gave is just a simple illustration of the problem. Acctually I
> have a more complicated code which calculates all sorts of things before
> outputing a graph. I don't think it would be possible to use functional
> programming code in my case.
> regards,
> Luiz

I believe that every problem is solvable in a functional style in
Mathematica, but you are right: sometimes the procedural approach is
more convenient or more efficient (though usually the reverse is
true).  I made that comment on For/While because beginners coming from
a procedural programming background tend to overuse these constructs.
If you are not one of them, please just ignore that comment :-)

This is just a subjective personal opinion, but I think that For[]
should be banished from the Mathematica language.  It is not only
completely redundant, but it is also ugly, and difficult to read for
people used to Mathematica code.  Unfortunately For[] is the first
thing beginners coming from a C background reach for ...  If Table[],
Nest[], Do[], etc. really don't do what one needs, then While[] should
be sufficient.

Szabolcs


  • Prev by Date: Re: GraphicsGrid
  • Next by Date: Controlling StepLeftButton and StepRightButton in Animator
  • Previous by thread: Re: ListLinePlot[] inside a loop
  • Next by thread: ToExpression again