1#
2# Normalize a nested list
3#
4# This routine replaces all the element delimiting whitespace
5# with a single space. This allows lsort to do the right
6# thing without triping on delimiting whitespace.
7#
8
9proc lnorm {list} {
10  set r {}
11  foreach el $list {
12    if {[llength $el] == 1} {
13      lappend r $el
14    } else {
15      lappend r [lnorm $el]
16    }
17  }
18  return $r
19}
20# Check equality of two arrays where any list entries
21# have no order significance
22
23proc arraysEq {ar1 ar2} {
24  upvar $ar1 mar1
25  upvar $ar2 mar2
26  if {![array exists mar1] ||\
27	  ![array exists mar2] ||\
28	  [array size mar1] != [array size mar2]} {return 0}
29  foreach ent [array names mar1] {
30    if {![info exists mar2($ent)] ||\
31	    [lsort  $mar1($ent)] != [lsort $mar2($ent)]} {return 0}
32  }
33  return 1
34}