Wolfram: Association. Check Value Exist

By Xah Lee. Date: . Last updated: .

Check Value Exist by Pattern

MemberQ[asso, pattern]

check value exist by Pattern. Return True if pattern matches a value.

(* check value exist by pattern *)

MemberQ[ Association[ a -> 3, b -> 2 ], 3 ]
(* True *)

MemberQ[ Association[ a -> 3, b -> 2 ], _Integer ]
(* True *)

MemberQ[ Association[ a -> 3, b -> 2 ], 9 ]
(* False *)
(* check if there's a value that's list of pairs with second part a even number *)
MemberQ[
Association[ a -> {9, 1}, b -> {3, 6} ],
 {_, _?EvenQ} ]
(* True *)

Wolfram. Association (Key Value List)