Reputation: 4820
TCL has a data structure called dict
which maintains a collection of key-value pairs.
Is there another data structure which maintains a collection of keys (with no values)?
If no, then maybe someone already wrote a simple adapter on dict
with empty values?
Upvotes: 2
Views: 1115
Reputation: 179
Another approach would be to accumulate everything into say, $bucket
.
Then do:
set uniqueItems [lsort -unique $bucket]
Upvotes: 1
Reputation: 1019
Just use a single list.
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"
}
Maybe you should ask a more specific question to get a more accurate answer.
An alternative for dict
is array
which doesn't preserve the order of keys.
Upvotes: 1
Reputation: 7237
You could use the tcllib package ::struct::set
.
http://tcllib.sourceforge.net/doc/struct_set.html
Upvotes: 4