[ Team LiB ] Previous Section Next Section

New and Enhanced List Commands

Tcl 8.4 added several new commands and options that increase performance when manipulating lists:

  • The new lset command allows you to directly change the value of an individual list element. This is much faster than using lreplace to replace the element with a new value. See "The lset Command" on page 66.

  • The lindex command now accepts multiple indices to allow retrieval of values in nested lists. See "Getting List Elements: llength, lindex, and lrange" on 68.

  • Many new options were added to lsearch for faster and more flexible list searching. You can use the -sorted, -ascii, -decreasing, -dictionary, -increasing, -integer, and -real options indicate that the list is already sorted in various ways, which allows lsearch to use a more efficient searching algorithm. TIP #80 added the -all, -inline, -not, and -start options, giving you the ability to do things such as retrieve multiple elements with a search. See "Searching Lists: lsearch" on page 69.

    [ Team LiB ] Previous Section Next Section