我正在寻找一个内置的函数,就像下面的pfilter-by-keys
:
(pfilter-by-keys '(:a :b) '(:c 10 :b 20 :a 4))
;; => (:B 20 :A 4)
它的代码非常简单:
(defun pfilter-by-keys (keys plist)
"List -> PList -> PList
Returns a new plist with only the keys/values correspondent to the given
keys."
(loop for (k v) on plist by #'cddr
when (member k keys :test #'equal)
append (list k v)))
CL有没有像上面这样的内置函数?
PS.:Alexandria有一个非常接近的函数:remove-from-plist
。
https://stackoverflow.com/questions/47497722
复制相似问题