List


The List function lists the contents of a value. The value may be a number, string, or a table. For a table, this function lists only the indexed array elements of the table. Nestest, or multi-dimensional tables are supported. Since only the array components are listed, the table keys are not listed. This function is indended for use with tables used as an array.

Syntax

List( value )

Remarks

If value is simple, as with a string or number, then List works like the Printf function by just listing the value. If value is a table, then only the indexed table elements are listed. In contrast, the TList function lists the entire table contents..

Examples

The following script creates a complex table and lists its contents.

t = { 5, "My Name", A=1, 6, {x=1, y= {2,3,4}}, 7 }

-- create a table

List( t )

-- list the table

This script prints the output below. Notice that only the array components are listed. The "hash" components, with key names A, x, and y, are not listed.

 5

 My Name

 6

 7

  

The script below lists a nexted table that consists entirely of arrays.

t = { 5, 6, {20,30,40}, 7 }

-- create a table (an array)

List( t )

-- list the result

This script lists the entire table content. There are no named keys so the table is a pure array.

 5

 6

  20

  30

  40

 7

Related Topics

Contents, Printf