-
Notifications
You must be signed in to change notification settings - Fork 4
/
TCL script to find the difference between the two lists.tcl
46 lines (45 loc) · 1.37 KB
/
TCL script to find the difference between the two lists.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#Written by : Udaya Shankar S
#dated: 9.11.2022
#TCL script to find the difference between the two lists
#Version 1.0
set a { 10 12 14 16 18 20 21}
set b { 10 12 15 16 18 20 25 27 28}
if {[llength $a] == [llength $b]} {
for {set i 0 } {$i < [llength $a] } {incr i} {
for {set j 0} {$j < [llength $b] } {incr j} {
if {[lindex $a $i] == [lindex $b $i]} {
puts "Lists a & b are equal at $i"
break
} else {
puts "Lists a & b are notequal at $i"
break
}
}
}
} elseif {[llength $a] > [llength $b]} {
for {set i 0 } {$i < [llength $a] } {incr i} {
for {set j 0} {$j < [llength $a] } {incr j} {
if {[lindex $a $i] == [lindex $b $i]} {
puts "Lists a & b are equal at $i"
break
} else {
puts "Lists a & b are notequal at $i"
break
}
}
}
} elseif {[llength $a] < [llength $b]} {
for {set i 0 } {$i < [llength $b] } {incr i} {
for {set j 0} {$j < [llength $b] } {incr j} {
if {[lindex $a $i] == [lindex $b $i]} {
puts "Lists a & b are equal at $i"
break
} else {
puts "Lists a & b are notequal at $i"
break
}
}
}
} else {
puts "Lists a and b are different"
}