on
TCL
- Get link
- X
- Other Apps
#!/usr/bin/tclsh
puts "Enter values of List A: "
gets stdin listA
puts "Enter values of List B: "
gets stdin listB
proc add_list {a b} {
set c {}
if { [llength $a] != [llength $b]} {
puts "\nList Length Is Not Equal. Try Again!"
} else {
foreach i $a j $b {
lappend c [ expr $i + $j]
}
puts "\nSummation of {$a} and {$b} is {$c}"
}
}
add_list $listA $listB
Enter values of List A:
1 2 3 4 5
Enter values of List B:
1 2 3 4 5
Summation of {1 2 3 4 5} and {1 2 3 4 5} is {2 4 6 8 10}
Enter values of List A:
1 2 3 4 5
Enter values of List B:
1 2 3 4
List Length Is Not Equal. Try Again!
Comments
Post a Comment