【发布时间】:2015-10-09 01:23:35
【问题描述】:
我想编写一个递归函数来检查列表,如果列表是升序,则返回 true,否则返回 NIL。如果列表为空,它仍然是正确的。我对 Lisp 完全陌生,所以它仍然很混乱。
(defun sorted (x)
(if (null x)
T
(if (<= car x (car (cdr x)))
(sorted (cdr x))
nil)))
【问题讨论】:
-
你快到了,但你需要修正语法 [例如(
标签: list recursion lisp common-lisp