Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How do you check whether a string is palindrome or not using TCL script?

Answer Posted / karthik

#without looping concept
proc pal {a} {
set b [string length $a]
set c [expr $b/2]
set d [expr $c + 1]
set e [expr $c - 1]
set strA [string range $a 0 $e]
set strB [string range $a $d $b]
set l1 [ split $strA {}]
set lA [lsort -increasing $l1]
set l2 [ split $strB {}]
set lB [lsort -increasing $l2]
set str1 [ join lA {}]
set str1 [ join $lA {}]
set str2 [ join $lB {}]
set v [string compare $str1 $str2]
if {$v == 0} {
puts "palindrome"
} else {
puts "Not a palindrome"
}
}

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

No New Questions to Answer in this Category !!    You can

Post New Questions

Answer Questions in Different Category