Code example from Playing with Keyed Lists on Mac OS X Tcl/Tk Aqua 8.4.2

;# Listing 5. Playing around with keyed lists

;# include Tcl eXtensions
package require Tclx

set periodic_table_list {
  {87 {Francium {Fr} {223} {2-8-18-32-18-8-1} } }
  {88 {Radium {Ra} {226} {2-8-18-32-18-8-2} } }
  {104 {Rutherfordium {RF} {261} {2-8-18-32-32-10-2} } }
  {105 {Dubnium {Db} {262} {2-8-18-32-32-11-2} } }
  {106 {Seaborgium {Sg} {263} {2-8-18-32-32-12-2} } }
  {107 {Bohrium {Bh} {262} {2-8-18-32-32-13-2} } }
  {108 {Hassium {Hs} {265} {2-8-18-32-32-14-2} } }
  {109 {Meitnerium {Mt} {266} {2-8-18-32-32-15-2} } }
  {110 {Ununnilium {Uun} {269} {2-8-18-32-32-17-1} } }
  {111 {Unununium {Uuu} {272} {2-8-18-32-32-18-1} } }
  {112 {Ununbium {Uub} {277} {2-8-18-32-32-18-2} } }
  {113 {Ununtrium {Uut} {undiscovered} {undiscovered} } }
  {114 {Ununquadium {Uuq} {285} {2-8-18-32-32-18-4} } }
  {115 {Ununpentium {Uup} {undiscovered} {undiscovered} } }
  {116 {Ununhexium {Uuh} {289} {2-8-18-32-32-18-6} } }
  {117 {Ununseptium {Uus} {undiscovered} {undiscovered} } }
  {118 {Ununoctium {Uuo} {293} {2-8-18-32-32-18-8} } }
}

;# create a Tcl list from the last element in the periodic_table_list
;# The first element in the list is at list index 0.
;# The last element in the list is at list index 16.
;#  the new list atom contains this:
;#  atom:  {118 {Ununoctium {Uuo} {293} {2-8-18-32-32-18-8} } }
set atom [lindex $periodic_table_list 16]

;# retrieve the data in the nested list
;# The first element, index 0, in the list atom, is the atomic number
;# The second element, index 1, is a nested list
;# atom_list: {Ununoctium {Uuo} {293} {2-8-18-32-32-18-8} }
set atom_data_list [lindex $atom 1]

;# Extracting the individual elements from the Tcl list, atom_data_list.
set element_name [lindex $atom_data_list 0]
set element_symbol [lindex $atom_data_list 1]
set atomic_weight [lindex $atom_data_list 2]
set electrons [lindex $atom_data_list 3]

;# display the atom data that was extracted
puts "$element_name $element_symbol $atomic_weight $electrons"

;# create a VERY simple Tclx keyed list, periodic_table 
keylset periodic_table $element_name.symbol $element_symbol
puts "\n Keyed list periodic table: \n $periodic_table"