Ex3.8 もしrightmostのkeywordパラメタの値が有効だったら
Ex3.8のちょっと前で定義したfind-allをKCLのパラメタバグに対応する問題。
前で行ったfind-allの定義は以下の通り。
(defun find-all (item sequence &rest keyword-args &key (test #'eql) test-not &allow-other-keys) "Find all those elements of sequence that match item. according to the keywords. Doesn't alter sequence." (if test-not (apply #'remove item sequence :test-not (complement test-not) keyword-args) (apply #'remove item sequence :test (complement test) keyword-args)))
変更したいkeywordパラメタをrestパラメタの右側に追加する。
;;; Exercise 3.8 [m] Some versions of Kyoto Common Lisp(KCL) have a ;;; bug wherein they use the rightmost value when more than one ;;; keyword/value piar is specified for the same keyword. Change the ;;; definition of find-all so that if works in KCL. (defun find-all (item sequence &rest keyword-args &key (test #'eql) test-not &allow-other-keys) "Find all those elements of sequence that match item. according to the keywords. Doesn't alter sequence." (if test-not (apply #'remove item sequence `(,@keyword-args :test-not ,(complement test-not))) (apply #'remove item sequence `(,@keyword-args :test ,(complement test)))))