判断回文的函数palindrome?
CL-USER> (defun palindrome? (x)
(let ((mid (/ (length x) 2)))
(equal (subseq x 0 (floor mid))
(reverse (subseq x (ceiling mid))))))
PALINDROME?
CL-USER> (palindrome? "abba")
T
CL-USER> (palindrome? "abcba")
T
CL-USER>
注:subseq函数只会取到第二个数字参数的前面
CL-USER> (subseq "hellolleh" 0 4)
"hell"