To provide more flexibility to our programs, it will be necessary to create and maintain your lists dynamically. As this will result in a list of indeterminate size, we need a means to determine the number of elements in a list. To accomplish this, Tcl provides the llength
command. The syntax is as follows:
llength list
In the following example, we will pass a list to the llength
command to determine the number of elements the list contains. Return values from the commands are provided for clarity. Enter the following command:
% llength {John Mary { Bill Tom }}
3
3.140.197.10