Alice Community

Alice Community (
-   Questions and Comments (
-   -   Array questions (

jrrTolkien 07-18-2014 09:53 AM

Array questions
I've used arrays in a few programming languages before, but I don't really understand how they work in Alice. And what's the difference between lists and arrays? And what are 1-dimensional arrays in Alice? I know what they are in some other programming languages, but not a 3-D one like this...


MrMoke 07-18-2014 02:37 PM

Thought you were Dead
Welcome Back JRR-
Arrays are pretty much the same in all programming languages. They are fixed length constructs of items that all have to be the same type. In older languages that meant all characters, integers, or Floating point values. In newer languages that definition has been expanded, but the rules are the same.
An array has a predefined length, which [U]cannot[/U] be changed. Each item can be accessed and/or replaced by assigning a specific value to the array's index pointer, then manipulating the referenced memory location. Accessing and/or storing information from multiple same-size arrays with the same index value, has been used for a long time in programming.

A one-dimensional array, like those in Alice, might hold something like all the integers from 0 to 9.

A two-dimensional array, which could be visualized as a box, might contain something like all of the pixels on your monitor, so accessing monitor(x,y) might access the pixel in row x, col y, or vice-versa depending how the programmer set it up.

A three-dimensional array could hold all the data points in an Alice World.

Any arrays larger than that makes my head hurt because it involves time travel :eek:

Lists look the same, and can be accessed in the same manner, but are somewhat more pliable in that the length is not fixed once they have been created. You can add, modify, and delete items from any position. Because of this, the length of a list can vary from moment to moment, so care must be taken when trying to use then the same way as an array.

In Alice, lists are given special attention when using commands like "For All Together", "For All In Order", etc.

jrrTolkien 07-21-2014 07:54 PM

Glad to know you were concerned
I actually didn't leave, the forum just has been pretty quiet and I didn't have anything to ask before. :) Anyway, thanks for your answer!


All times are GMT -5. The time now is 08:05 AM.

Copyright ©2021, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.