Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,17 @@
|
|||
# Create one element at a time:
|
||||
set hash(foo) 5
|
||||
|
||||
# Create in bulk:
|
||||
array set hash {
|
||||
foo 5
|
||||
bar 10
|
||||
baz 15
|
||||
}
|
||||
|
||||
# Access one element:
|
||||
set value $hash(foo)
|
||||
|
||||
# Output all values:
|
||||
foreach key [array names hash] {
|
||||
puts $hash($key)
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# Create in bulk
|
||||
set d [dict create foo 5 bar 10 baz 15]
|
||||
|
||||
# Create/update one element
|
||||
dict set d foo 5
|
||||
|
||||
# Access one value
|
||||
set value [dict get $d foo]
|
||||
|
||||
# Output all values
|
||||
dict for {key value} $d {
|
||||
puts $value
|
||||
}
|
||||
# Alternatively...
|
||||
foreach value [dict values $d] {
|
||||
puts $value
|
||||
}
|
||||
|
||||
# Output the whole dictionary (since it is a Tcl value itself)
|
||||
puts $d
|
||||
Loading…
Add table
Add a link
Reference in a new issue