HyperMath

Tables - Data Types

Tables - Data Types

Previous topic Next topic No expanding text in this topic  

Tables - Data Types

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

HyperMath supports a general-purpose aggregate data type called a table.  Aggregate data types are used for storing collections, such as lists, sets, and arrays.  Aggregate data types can store associative arrays that contain other objects, including numbers, strings, or even other aggregates.

Tables are created using a pair of curly brackets, {}.  The example below creates an empty table:

> x = {}

> print(x)

table: 0035C910

It is normal if your table does not have the same unique identifier as in the above example.

When the value of a table variable is displayed using the built-in print function, HyperMath displays the variable as a table and a unique identifier for that table (its address in memory).  You can also print the contents of a table.

You can construct tables containing mixed objects, such as the numbers and strings as described above.  For example:

> x = {123,"hello"}

> print(x[1])

123

> print(x[2])

hello

Table indexing is one-based by default (first element is indexed by one) and requires a pair of square brackets, [], for indexing as shown above.  Although tables can store numbers, they are not equivalent to vector and matrix data types in the sense that no matrix operations are defined on them.  Vectors and matrix data structures are recommended over tables for numerical calculations.

See Also:

Introduction to Tables