MathGroup Archive 2000

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

Search the Archive

Re: Manipulating List Elements In Programs

  • To: mathgroup at
  • Subject: [mg23968] Re: Manipulating List Elements In Programs
  • From: "Atul Sharma" <atulksharma at>
  • Date: Sun, 18 Jun 2000 03:00:50 -0400 (EDT)
  • Organization: McGill University
  • References: <8icdhn$>
  • Sender: owner-wri-mathgroup at

When you use Delete this way, you haven't actually redefined your list z. As
in this example, z hasn't been changed.

z= {a, b, c, d};
Delete[z, 3]

{a, b, d}
{a, b, c, d}

What you really want to do is redefine the list, as in


{a, b, d}
{a, b, d}

In you case, you may also find z=Rest[z] a convenient way to trim element 1
from the list.


Atul Sharma MD, FRCP(C)
Pediatric Nephrologist,
McGill University/Montreal Children's Hospital

Buz Barstow wrote in message <8icdhn$9sk at>...
>I'm trying to write a program in Mathematica to automatically plot graphs
>from text files that I've generated with a C program. It looks in the
>working directory, and retrieves a list of all files with a .dat extension;
>files = FileNames["output*.dat"]
>Then, it gets the number of entries in that list;
>l = Length[files]
>And then uses this information to import each file individually and do a
>ListPlot with each list;
>For[i = 1, i <= l, i++,
>  z = Import[ files[[i]]];
>  title = z[[1]];
>  lab = z[[2]];
>  Delete[z, {1, 2}];
>  ListPlot[z, AxesLabel -> lab, PlotLabel -> title] ]
>At the top of each output file there is a heading that I want to use as the
>plot's title and two column headings that I want to use to label the axes.
>Unfortunately, I can retrieve them and label the plot, but I can't delete
>them, so when I include the title, I can't produce the plot.
>Does Mathematica prevent the programming calls deleting things, or am I
>missing something?
>Thanks in advance,

  • Prev by Date: Re: Fonts & Printing
  • Next by Date: Re: problems saving and opening notebooks using menus
  • Previous by thread: RE: Manipulating List Elements In Programs
  • Next by thread: Re: Manipulating List Elements In Programs