Skip to content

list

Creates a list from the given arguments.

Syntax

tcl
list ?arg arg ...?

Parameters

  • arg: Optional values to include in the list

Description

Returns a list comprised of all the arguments. When called with no arguments, returns an empty list.

The list command works directly from original arguments, preserving their structure. This is different from concat, which removes one level of grouping from its arguments. Braces and backslashes are added as necessary so that lindex can re-extract the original arguments unchanged.

Examples

Creating a simple list

Output

Empty list

Output

List with spaces in elements

Output

Preserving argument structure

Output

Difference from concat

Output

See Also

  • concat - Concatenate arguments (removes one level of grouping)
  • lappend - Append to list variable
  • llength - Get list length
  • lindex - Get element by index