ELisp: Check Element Exist in List

By Xah Lee. Date: . Last updated: .
member
(member x list)

Check if x is in list. If so, return a list starting with the first occurrence of object. Else return nil.

Comparison done using equal.
(member "4" '("3" "4" "5")) ;; ("4" "5")
member-ignore-case
(member-ignore-case x list)

same as member, except that x should be a string, and comparison ignores letter-case.

(member-ignore-case "A" '("b" "a")) ; ("a")
memq
(memq x list)

Same as member, but comparison done using eq. Use this if all items are Symbols.

memql
(memql x list)

Same as member, but comparison done using eql.

Reference

Emacs Lisp List

Special Lists

List Structure