PDA

View Full Version : Arrays only 1D?


Niteshifter
03-03-2009, 11:33 PM
I'm trying to play around with arrays, but I can only see that arrays are about as useful as a list, or in other words, they're only 1D. I'm unable to add more than one object to an array in alice, so I can't make them 2D. Is there a way to make arrays 2D or more in alice, or is an array in alice exactly like using a list, but with a different symbol (All the tutorials I've found show what it is, but aren't exactly specific, and are pretty vague in the answer as well as how to do it).

wongwanchap
03-04-2009, 02:19 AM
As I know, list is better for me.

The different between array and list is:
Array can't increase the length, but list can't.
We can directly change the value of element inside array, but we can't directly do so in list, in order to change the value in list, we need to first delete that element, that add the new element at the position with the value you want to change.

Actually, I don't know why Alice don't combine those function together, so it can have the advantage of both.

Scott300
03-04-2009, 08:32 AM
As I know, list is better for me.

The different between array and list is:
Array can't increase the length, but list can't.
We can directly change the value of element inside array, but we can't directly do so in list, in order to change the value in list, we need to first delete that element, that add the new element at the position with the value you want to change.

Actually, I don't know why Alice don't combine those function together, so it can have the advantage of both.

I would love something like a database tool instead of arrays/lists over all anyways =D

DrJim
03-04-2009, 11:44 AM
Actually, I don't know why Alice don't combine those function together, so it can have the advantage of both.

The why is easy. You want a list for stack operations (push and pop) but an array for matrix work. Also, the 1D restriction on arrays is part of Java - however there you can easily make an array of arrays and get a normal (i.e., Basic or C++ like) multi-dimensional array. I haven't figured out how to do that in Alice - but also really haven't tried very hard :rolleyes:.

As far as database programming goes - I've never heard that OOP is the way to go for that application.

Niteshifter
03-07-2009, 03:23 PM
I guess I'm going to have to go onto a different approach to make the thing I'm making because a multi-dimensional array would make the job a lot easier.