Intel® Quartus® Prime Pro Edition User Guide: Scripting

ID 683432
Date 12/13/2021

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

2.9.5. Lists

A Tcl list is a series of values. Supported list operations include creating lists, appending lists, extracting list elements, computing the length of a list, sorting a list, and more.
set a { 1 2 3 }

You can use the lindex command to extract information at a specific index in a list. Indexes are zero-based. You can use the index end to specify the last element in the list, or the index end-< n> to count from the end of the list. For example, to print the second element (at index 1) in the list stored in a use the following code.

puts [lindex $a 1]

The llength command returns the length of a list.

puts [llength $a]

The lappend command appends elements to a list. If a list does not already exist, the list you specify is created. The list variable name is not specified with a dollar sign (“$”).

lappend a 4 5 6