User:Brian P. Josey/Notebook/2010/08/10

From OpenWetWare

Jump to: navigation, search
Project name Main project page
Previous entry      Next entry

Arrays

Arrays are groups of data elements that have are composed of the same type. Each array consists of the elements, and dimensions that specify the number of elements possible and their orientation in respect to how they are stored. They are ordered and can be indexed. A simplified example on how to create an array, is to generate a string of random numbers, and organize them into the array. To do this, you could simply create a for loop that generates a random number, and output it to an array. To create a two dimensional array, nest a for loop into another. The inner loop will create the columns, while the outer loop will create the rows.

Several important functions that can act on an array are:

  • Array Size which gives the size of the array,
  • Initialize Array will create an array that each element is initialized to a value,
  • Array Subset will return a portion of an array, starting at an index,
  • Build Array will concatenate two or more arrays into one,
  • Index Array will return the elements, or a sub-array of another array at an index,

Clusters

Clusters are similar to arrays in that they bundle different pieces of data together, but are different in that arrays only bundle together data of the same type, while a cluster generalizes this to several different types of data. While an array could be thought as a dictionary, containing only the definitions for words, a cluster would be a multiple subject notebook, with notes on physics, history and French cuisine on different pages.

Personal tools