by shigemk2

当面は技術的なことしか書かない

対話によるCommon Lisp入門 48 and その2

itemがlstの要素であるためには、

lstが空リストでないこと

(not null lst))

lstの先頭要素がitemであるか、

(eql item (first lst))

もしくはitemはリストの残りの部分の要素であるかである。

(member? item (rest lst))
(defun member? (item lst)
  (and (not (null lst))
       (or (eql item (first lst))
           (member? item (rest lst)))))


(print (member? 'c '(a b c d)))
(print (member 'c '(a b c d)))


結果

T
(C D)