WolframLang: Check Item Exist in List
MemberQ
-
MemberQ[ expr, pattern ]
MemberQ[ expr, pattern, levelspec ]
→ limit to Level Spec.
Check existence by Pattern.
default Level Spec is
{1}
MemberQ[ {1, 2, 3}, 2 ] (* True *) MemberQ[ {1, {a, b}, 3}, {a, b} ] (* True *)
(* using a pattern *) MemberQ[ {1, {a, b}, 3}, {_, _} ] (* True *) MemberQ[ {1, {a, b}, 3}, _Integer ] (* True *)
Count
-
Count[ expr, pattern ]
Count[ expr, pattern, levelspec ]
→ limit to Level Spec.
Count by Pattern
default Level Spec is
{1}
Count[ {1, 2, 3, 1}, 1 ] (* 2 *) Count[ {1, {a, b}, 3}, {a, b} ] (* 1 *)
(* using a pattern *) Count[ {1, {a, b}, 3}, {_, _} ] (* 1 *) Count[ {1, {a, b}, 3}, _Integer ] (* 2 *)
(* using a levelspec *) Count[ {1,{2,{3,4}}}, {_, _} ] (* 1 *) Count[ {1,{2,{3,4}}}, {_, _}, {1,Infinity} ] (* 2 *)
Get an Element's Position
Position
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 Exist in List
- WolframLang: Filter List
- WolframLang: Sort, Reverse, Order
- WolframLang: List Reshape (split, group, flatten, transpose)
- WolframLang: List Combinatorics
- WolframLang: List Join, Union, Intersection, Difference