Joining two lists
Now that we have seen how to make a list we will explore combining lists. To accomplish this, Tcl provides the concat
command. The syntax is as follows:
concat value1 value2 …
How to do it…
In the following example, we will concatenate a set of lists containing single characters. Return values from the commands are provided for clarity. Enter the following command:
% concat {a b c} {1 2 3} a b c 1 2 3
How it works…
The concat
command joins each of its arguments together with spaces after first trimming all leading and trailing whitespace, and in the case of a list, the results will be flattened. Although this command will concatenate any arguments provided, we will be focusing on its usage as it applies to the list elements. To denote that a list is being provided as the argument, it should be encased within braces {}. This is another method of providing lists. They may also be passed as named list variables, actual list commands, or within quotes. If no arguments are provided...