How do you check whether a string is palindrome or not using TCL script?
Answer Posted / ajun
set a "mumy"
set b [lindex $a 0]
set c [split $a ""]
set d [llength $c]
set e [expr $d -1]
for {set i $e} {$i >= 0} {incr i -1 } {
lappend new [lindex $c $i]
}
set f [join $new {}]
set g [string compare $a $f]
if {$g == 0} {
puts " $a is palindrome \n"
} else {
puts "$a is not palindrome\n";
}
Is This Answer Correct ? | 6 Yes | 1 No |
Post New Answer View All Answers