【发布时间】:2017-07-21 05:27:02
【问题描述】:
我需要从公共列表中的列表中删除最后两个元素,但我只能删除一个。有什么办法?
(defun my-butlast (list)
(loop for l on list
while (rest l)
collect (first l)))
【问题讨论】:
-
while (rest (rest l))? -
@melpomene 我正在尝试不同的方法来实现它
-
(remove-if #'atom '(1 2 3 (1 2 3 4) 5) :count 2 :from-end t)=>(1 2 (1 2 3 4)). -
@jkiiski 您能否将它集成到 a 函数中。plz MyList = ( A B C D)..我正在尝试编写一个函数以从列表中删除 C D。使其变为 Mylist = (A B)
-
(subseq list :start 0 :end (- (length list) 2))- 这将是我的 goto 解决方案
标签: common-lisp