Common Lisp 序列编辑函数(remove和朋友)使用:count关键字参数:
Count(如果提供)限制删除或删除的元素数量; 如果多个count元素满足测试,则在这些元素中,只有最左边或最右边(取决于from-end)被删除或删除,与count指定的数量一样多.如果提供了count并且为负数,则行为就好像已经提供了零.如果是count
nil,则所有匹配项都会受到影响.
例如:
ELISP> (require 'cl)
cl
ELISP> (remove* 1 '(1 2 1 3 1 4) :count 1)
(2 1 3 1 4)
ELISP> (remove* 1 '(1 2 1 3 1 4) :count 2)
(2 3 1 4)
ELISP> (remove* 1 '(1 2 1 3 1 4) :count 2 :from-end t)
(1 2 3 4)
Run Code Online (Sandbox Code Playgroud)
(注意,Emacs已经调用了自己的函数remove,因此cl包必须使用该名称remove*.)