Check Palindrome - LISP

Program:
(defun palindrome()
(format t "Enter the string(in \"\"):")
(setf x (read))
(if(string= x (reverse x))
    (format t "palindrome")
    (format t "Not palindrome")
    )                                                                          
)


Output:
[1]> (load 'pal.lsp)
;; Loading file pal.lsp ...
;; Loaded file pal.lsp
T
[2]> (palindrome)
Enter the string(in ""):"malayalam"
palindrome
NIL
[3]> (palindrome)
Enter the string(in ""):"HAI"
Not palindrome
NIL
 [4]>


0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...