1
我试图从n位置获取元素到m位置。但我得到一些错误。 我该如何解决?Lisp从列表中获取元素
(defun element (list start end)
(dotimes (start end) (n-esimo list start)
))
(defun n-esimo (l n)
(cond ((equal n 0) (first l))
(t (n-esimo (rest l) (- n 1)))))
你会得到什么错误? – 2012-01-30 23:32:38
获取NIL。没有错误,但只有零和我的列表不是空的 – marchetto91 2012-01-30 23:41:03
'N-esimo'已经存在于Common Lisp标准中,它被称为'nnth'(尽管它反过来需要参数)。 “Dotimes”不符合你的想法。在Hyperspec中查看它,例如通过google搜索“clhs dotimes”。 – Svante 2012-01-31 20:55:35