How do you check whether a string is palindrome or not using TCL script?
Answer Posted / anonymous
proc is_palindrome { input_string } {
set input_string [string tolower $input_string] ; # Convert to lower case for case insensitive comparison
set input_string [string map {"" ""} $input_string ;# Remove Spaces
set reversed_string [string reverse $input_string]
return [string equal $input_string $reversed_string]
}
# To test use is_palindrome kayak from tclsh
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
No New Questions to Answer in this Category !! You can
Post New Questions
Answer Questions in Different Category