Alice Community  

Go Back   Alice Community > General Discussion > Questions and Comments

Reply
 
Thread Tools Display Modes
Array questions
Old
jrrTolkien
Senior Member
 
jrrTolkien's Avatar
 
Status: Offline
Posts: 166
Join Date: Feb 2014
Location: Middle-Earth (Merrimack, NH)
Question Array questions - 07-18-2014, 10:53 AM

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...

-jrr


Arwen: I would rather share one lifetime with you than face all the Ages of this world alone.

-April Signature
   
Reply With Quote
Thought you were Dead
Old
MrMoke
Senior Member
 
MrMoke's Avatar
 
Status: Offline
Posts: 501
Join Date: Sep 2007
Location: Austin, Texas
Default Thought you were Dead - 07-18-2014, 03:37 PM

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 cannot 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

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.

Last edited by MrMoke; 07-22-2014 at 01:31 PM.
   
Reply With Quote
Glad to know you were concerned
Old
jrrTolkien
Senior Member
 
jrrTolkien's Avatar
 
Status: Offline
Posts: 166
Join Date: Feb 2014
Location: Middle-Earth (Merrimack, NH)
Wink Glad to know you were concerned - 07-21-2014, 08:54 PM

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!

-Jrr


Arwen: I would rather share one lifetime with you than face all the Ages of this world alone.

-April Signature
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



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