# There is no equivalent to $#ARRAY in Tcl.
procwhatAboutThatList args {
variable people
append res "The list now has [set len [llength $people]] elements.\n"
append res "The index of the last element is [incr len -1].\n"
append res "Element #3 is `[lindex $people 3]'."
}
set people [list Crosby Stills Nash Young]
whatAboutThatList
# => The list now has 4 elements.
# => The index of the last element is 3.
# => Element #3 is `Young'.
set people [lrange $people 0 end-1]
whatAboutThatList
# => The list now has 3 elements.
# => The index of the last element is 2.
# => Element #3 is `'.
# append 10001-(length of list) null elements to the list:
for {set i [llength $people]} {$i <= 10000} {incr i} {
lappend people {}
}
whatAboutThatList
# => The list now has 10001 elements.
# => The index of the last element is 10000.
# => Element #3 is `'.

variable res {}
set fruits [list Apple Blackberry]
set fruitRef fruits
# the variable fruitRef is now set to the name of the fruit list,
# which makes it a kind of reference variable
foreach fruit [set $fruitRef] {
append res "$fruit tastes good in a pie.\n"
}
puts $res
# => Apple tastes good in a pie.
# => Blackberry tastes good in a pie.

lsort -unique [list how much wood would a wood chuck chuck]
# => a chuck how much wood would
# This is an order of magnitude slower than the previous solution.
foreach e $list {
array set unique [list $e {}]
}
array names unique
# => a wood much chuck how would

set members [list Time Flies]
lappend members An Arrow
# => Time Flies An Arrow
set members [list Time Flies]
set initiates [list An Arrow]
set members [concat $members $initiates]
# => Time Flies An Arrow
set members [list Time Flies An Arrow]
set members [linsert $members 2 Like]
# => Time Flies Like An Arrow
set members [list Time Flies Like An Arrow]
set members [lreplace $members 0 0 Fruit]
set members [lreplace $members end-1 end A Banana]
# => Fruit Flies Like A Banana