Sunday, December 6, 2015

TCL arrays

TCL array: (Under construction)

  • Array is a collection of variables.
  • Associative  -> abstract data type composed of a collection of key value pairs. 
  • Key value pairs are not ordered.
  • Each variable can hold any value or an array.

How to create an array in tcl?
  • We can create an array using set or "array set"
Array operations :
Different operations associated with array


array exists
array get
array names
array set
array size
array unset
array startsearch
array nextelement
array anymore
array donesearch
array statistics



Output: 
sat and Saturday are same
wed and Wednesday are same
fri and Friday are same
thu and Thursday are same
sun and Sunday are same
tue and Tuesday are same
mon and Monday are same

Note: Observe that key and value pairs are not ordered.

Example:2

Output:
4 is associated to  Thu
5 is associated to  Fri 
1 is associated to  Mon 
6 is associated to  Sat 
2 is associated to  Tue 
7 is associated to  Sun 
3 is associated to  Wed

All array operations are listed in this example
Example:3


Example:4


No comments: