memq
OBJECT LIST -> LIST
メンバーかどうか確認する
code: fns.c
DEFUN ("memq", Fmemq, Smemq, 2, 2, 0,
doc: /* Return non-nil if ELT is an element of LIST. Comparison done with `eq'.
The value is actually the tail of LIST whose car is ELT. */)
(Lisp_Object elt, Lisp_Object list)
{
Lisp_Object tail = list;
FOR_EACH_TAIL (tail)≤
if (EQ (XCAR (tail), elt))
return tail;
CHECK_LIST_END (tail, list);
return Qnil;
}
code: example.el
(memq 1 '(1 2 3))
;; => (1 2 3)
(memq 2 '(1 2 3))
;; => (2 3)
(memq 3 '(1 2 3))
;; => (3)
(memq 4 '(1 2 3))
;; => nil