Freigeben über


Features of Small Basic Array

Array in Small Basic has following features.

  • associative array
  • flexible length
  • index is case-insensitive
  • null value removes the index
  • multiple dimension

Associative Array

In Small Basic, an index of an array does not have to be an integer number.  A text such like "id" can be used as an index.  Generally this kind of array is called associative array.  This allows to use an array (ex. tortoise["x"]) like an object property (ex. Turtle.X).  And also allows that the indices are not continuous.

Flexible Length

Both lengths of an index and a value in an array are flexible.  Some program languages have fixed length for each entry of array.

Index is Case-Insensitive

For example, star["γ"] and star["Γ"] is the same.

Null Value Removes the Index

Substituting null value ("") to an entry of an array causes removing the entry.  This feature is sometimes useful for performance.  A large array may slow down the program speed.  Removing no need entry shrinks the array and may improve the performance.

For example, chessboard is not fully filled with chessmen.  Imagine to count chessmen on a chessboard.   If the empty squares are removed in the chessboard array, chessmen can be easily count with Array.GetItemCount() operation.  Like this chessboard array, the array which has many empty entry is called sparse array.   So this feature is useful for sparse array.  Actually the program PRL427-1 uses sparse array to represent the Menger Sponge.  That has improved the performance of this program.

Screen shot of a program Menger Sponge 0.2

Multiple Dimension

1-D array can be written such as day[26].  2-D array can be written such as chessboard[row][col].  3-D array can be written such as block[z][y][x].  And so on.

See Also

Comments

  • Anonymous
    October 09, 2016
    The comment has been removed
    • Anonymous
      October 13, 2016
      YLed, thank you for your comment.