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. Else return nil.

Comparison done using equal. [see Elisp: Equality Test]

(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 or int.

[see Elisp: Equality Test]

memql
(memql x list)

Same as member, but comparison done using eql.

[see Elisp: Equality Test]

Reference

Emacs Lisp List

Special Lists

List Structure