Array

From Alteeve Wiki
Jump to navigation Jump to search

 AN!Wiki :: Array

An array, in programming terms, usually refers to an indexed collection of elements. The index is usually numerical, with each element being added increasing the index count and each removal of an element reducing it. Generally there is no direct relation between an index position and which element it points to. An entry in an array may move around within the array as the array itself is modified.

  • Arrays are generally faster than dictionaries/hash tables.

Arrays are often expressed as:

  • Creating an array with four elements:
array=("first_element", "another_element", 12, "30.5")
  • Retrieving the first element:
print array[0];    # Prints "first_element".
  • Removing the first element, then reprinting the first element.
shift array;       # Shift the first element off the array, shortening the array by 1.
print array[0];    # Prints "another_element" now, because "first_element" has been removed.

In Perl, arrays are preceded with the '@' symbol.

 

Any questions, feedback, advice, complaints or meanderings are welcome.
Alteeve's Niche! Enterprise Support:
Alteeve Support
Community Support
© Alteeve's Niche! Inc. 1997-2024   Anvil! "Intelligent Availability®" Platform
legal stuff: All info is provided "As-Is". Do not use anything here unless you are willing and able to take responsibility for your own actions.