Intel® Quartus® Prime Standard Edition User Guide: Scripting

ID 683325
Date 9/24/2018
Public
Document Table of Contents

2.13.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