【发布时间】:2012-01-07 17:29:07
【问题描述】:
【问题讨论】:
标签: list data-structures dictionary set tcl
【问题讨论】:
标签: list data-structures dictionary set tcl
你可以使用 tcllib 包::struct::set。
【讨论】:
只使用一个列表。
set example [list "key1" "key2" "key3"]
if {[lsearch -exact $example "key3"] != -1} {
puts "found your key!"
} else {
puts "your key is not in the list"
}
也许您应该问一个更具体的问题以获得更准确的答案。
dict 的替代方案是 array,它不保留键的顺序。
【讨论】:
if {"key3" in $example} { ... 代替lsearch(8.5 中引入的运算符)。
另一种方法是将所有内容累积成$bucket。
然后做:
set uniqueItems [lsort -unique $bucket]
【讨论】: