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