-1 lisp common-lisp
我是lisp的新手,我有一个问题,我正在尝试在列表中找到该号码,但它无效.我还没有发表回复声明
(defun num (x 'y)
    (if (member x '(y)) 't nil))
(write (num 10 '(5 10 15 20)))
我的输出只输出nil而不是执行功能,我对我做错了很困惑.
(defun member-p (element list)
  "Return T if the object is present in the list"
  (not (null (member element list))))
的not/ null模式等同于(if (member element list) t nil)但更常见.
事实上,你真的不需要这个单独的功能,
 member足够好.
该-p后缀代表断言,比照 integerp和upper-case-p.
defun num (x 'y)与defun num (x y)t'(y)毫无意义,用它替换y.write函数调用,REPL会为你做.| 归档时间: | 
 | 
| 查看次数: | 166 次 | 
| 最近记录: |