LISP program to check whether a given string is a palindrome
kw.lisp
(write-line "———————————————————————————————————————————")
(write-line "Program to check whether string is palindrome")
(write-line "———————————————————————————————————————————")
(princ "Enter the string ")
(setq s(string(read)))
(setq s1(string s))
(setq s2(reverse s1))
(if (string-equal s1 s2)
(format t "~%~d is palindrome"s1))
(if (string-not-equal s1 s2)
(format t "~%~d is not palindrome"s1))
(terpri)(princ "———————————————————————————————————————————")
Output
kodingwindow@kw:~$ clisp kw.lisp
———————————————————————————————————————————
Program to check whether string is palindrome
———————————————————————————————————————————
Enter the string LOYAL

LOYAL is not palindrome
———————————————————————————————————————————

kodingwindow@kw:~$ clisp kw.lisp
———————————————————————————————————————————
Program to check whether string is palindrome
———————————————————————————————————————————
Enter the string LOL

LOL is palindrome
———————————————————————————————————————————
kodingwindow@kw:~$ 
What Next?
LISP Functions
Advertisement