【发布时间】:2019-11-16 02:18:03
【问题描述】:
我写了这样一个函数来反转一个列表
练习 2.18。定义一个以列表为参数并以相反顺序返回相同元素的列表的过程 reverse:
#+begin_src emacs-lisp :session sicp :lexical t
(defun reversex(item)
(cond
((null item) nil)
((cons (reversex (cdr item))
(car item)))
))
(reversex (list 1 4 9 16 25))
#+end_src
第一次运行得到以下输出:
#+RESULTS:
: (((((nil . 25) . 16) . 9) . 4) . 1)
但是第二次运行,报错:
Wrong argument type listp, "GIF"
【问题讨论】: