WolframLang: Check Item Existence in List
MemberQ
-
Check existence by Pattern
MemberQ[ {1, 2, 3}, 2 ] === True MemberQ[ {1, {a, b}, 3}, {a, b} ] === True
Count
-
Count by Pattern
Count[ {1, 2, 3, 1}, 1 ] === 2 Count[ {1, {a, b}, 3}, {a, b} ] === 1
Position[expr, pattern]
-
Return a list of positions that Pattern occur in expression. If not exist, return a empty list.
xx = {a, {{b, c}, a}, e}; (* position of e is {3} *) Position[ xx, e ] === {{3}} (* position of a is {1} and {2, 2} *) Position[ xx, a ] === {{1}, {2, 2}} (* when not found, empty list *) Position[ xx, m ] === {} (* position of b *) Position[ xx, b ] === {{2, 1, 1}} (* position of {b, c} *) Position[ xx, {b, c} ] === {{2, 1}}
WolframLang List Operations
- WolframLang: List Operations
- WolframLang: Get Parts of List
- WolframLang: Add Element to List
- WolframLang: Delete Element in List
- WolframLang: Change Element in List
- WolframLang: Check Item Existence in List
- WolframLang: List Order Functions
- WolframLang: List Restructure Functions
- WolframLang: List Combinatorics
- WolframLang: List Join, Union, Intersection, Difference