       Re: Simple List question. HELP.

• To: mathgroup at smc.vnet.net
• Subject: [mg39404] Re: [mg39389] Simple List question. HELP.
• From: Jan Mangaldan <hokenjan at yahoo.com>
• Date: Fri, 14 Feb 2003 03:18:36 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```This works:
In:= lst = {};
In:= AppendTo[lst, {0, 1}]
Out:= {{0, 1}}
In:= AppendTo[lst, {1, 2}]
Out:= {{0, 1}, {1, 2}}
In:= AppendTo[lst. {2, c}]
Out:= {{0,1}, {1, 2}, {2, c}}
You can find out more about AppendTo[] in The Mathematica Book.
Jan M. (^_^)

P.S. You can repeat the procedure as many times as necessary to keep adding elements to your list.
Of course, it would be better if you just type-in the whole list.
Daniel Heneghan <dhenegha at bway.net> wrote:
I am new to Mathematica. This is vexing. All I want to do is create a
2-dimensional list so that I can enter x,y values and then plot the
list. I want to do this programmatically. I am having such incredible
trouble trying to accomplish this simple task. I know that there is
probably a Mathematica optimized way to do this, but I and trying to
write a little program and for now I want to stay with paradigms that I
am familiar with. Here is what I have been doing.

Create a 2 dimensional list.
In lst={{}}
Out= {{}}

Enter the first pair into the first place in the list.
In:= lst={{0,1}}

Errors and beeps here, but it does seem to record the correct values.
Set::write: Tag List in {{}} is Protected.
Out={{0,1}}

In:= lst=Append[lst,{{1,2}}]
Out= {{},{{1,2}}}
The second pair is OK, but the first pair has been obliterated.

Add another pair. Now all subsequent entries are OK, but I still have
lost the first pair.
In:= lst=Append[lst,{{2,c}}]
Out= {{},{{1,2}},{{2,c}}}--

What is going on? What are the mysteries of working with lists in
Mathematica. In any programming language this is simple. I can't grasp
it in Mathematica. The reason I need to do this is that for the list
plot I need the x values to start at 0 not 1.

Thanks,

Daniel Heneghan
Ceara Systems
(212) 696-9208
ceara at bway.net

```

• Prev by Date: Re: Bug in ColorFunctionScaling ???
• Next by Date: Re: Simple List question. HELP.
• Previous by thread: Re: Simple List question. HELP.
• Next by thread: Re: Simple List question. HELP.