下面的代码:
(defun last-pair-2(item)
(cond
((not (consp item)) item)
(t (last-pair-2(item)))
))
(last-pair-2 (list 23 43 128 3))
报错:
last-pair: Symbol’s function definition is void: item
有什么问题呢?
null判断没有问题
#+begin_src emacs-lisp :tangle yes
(defun last-pair(item)
(if (null (cdr item)) (car item)
(last-pair (cdr item))))
(last-pair (list 23 43 128 3))
#+end_src
#+RESULTS:
: 3