MathGroup Archive 1995

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

Search the Archive

Re: LISTS and more LISTS

  • To: mathgroup at
  • Subject: [mg2840] Re: LISTS and more LISTS
  • From: wagner at bullwinkle.cs.Colorado.EDU (Dave Wagner)
  • Date: Sat, 23 Dec 1995 03:19:58 -0500
  • Organization: University of Colorado, Boulder

In article <4bancs$cqu at>,
cjkelly at <cjkelly at> wrote:
>Enclosed is a little ditty I've been trying to get to work but as is
>clear, it has a bug and I have no clue as to what is wrong. 
>It is just supposed to extract elements out of a LIST then peform 
>various operations on these elements one of which is to plot a
>series of lines (or rays) starting from the point {25,5}
>Clear [f,x]
>Do [Line[{{5,25},{x[[i]],f[x[[i]]]}},{i,Length [x]}]]

You had a number of problems.  The first one is,

    f[x_] := x^2

Using "=" instead of ":=" caused f[x_] to be defined as {10,8,6,...}^2,
which isn't what you wanted.

Next, your square brackets weren't balanced correctly.  To identity
problems like this, see if your version of the front end has a
"Balance" command in one of its submenus (on the Mac, it's in the
"Nesting" submenu of the "Edit" menu).

                                       ^ this got moved

Finally, when you get those problems fixed, you don't get any output
from Do.  To get output, use Table:


    {Line[{{5, 25}, {10, 100}}], Line[{{5, 25}, {8, 64}}], Line[{{5, 25},
    {6, 36}}], Line[{{5, 25}, {5.5, 30.25}}], Line[{{5, 25}, {5.4,
    29.16}}], Line[{{5, 25}, {5.3, 28.09}}], Line[{{5, 25}, {5.2, 27.04}}],
    Line[{{5, 25}, {5.1, 26.01}}], Line[{{5, 25}, {5.01, 25.1001}}],
    Line[{{5, 25}, {5.001, 25.01}}], Line[{{5, 25}, {5.0001, 25.001}}],
    Line[{{5, 25}, {5.0001, 25.001}}]}

You can plot the result using


		Dave Wagner
		Principia Consulting
		(303) 786-8371
		dbwagner at

  • Prev by Date: Re: shell command
  • Next by Date: Re: Programming
  • Previous by thread: LISTS and more LISTS
  • Next by thread: Thanks for help with lists (all who replied)