小编nes*_*een的帖子

如何在lisp中检查列表是否为回文?

我想通过比较第一个元素和最后一个元素来测试这个列表是否是回文,第二个元素与最后一个元素之前比较等等

(setq l '(1 5 7 8 8 7 5 1))
(defun f (l)
  (cond ((null l) 0)
        ((atom l) l)
        (if       (equal (car l) (car(cdr l))))
Run Code Online (Sandbox Code Playgroud)

lisp common-lisp palindrome

2
推荐指数
1
解决办法
4758
查看次数

标签 统计

common-lisp ×1

lisp ×1

palindrome ×1