# Wolfram Language™

## Pattern Matching with Associations

Version 11 introduces several functions to simplify the manipulation and pattern matching of associations.

Use KeyMemberQ and KeyFreeQ to test whether or not a key is part of an association.

In:= `KeyMemberQ[<|a -> 1, b -> 2, c -> 3|>, a]`
Out= In:= `KeyFreeQ[<|a -> 1, b -> 2, c -> 3|>, a]`
Out= KeyValuePattern allows you to match a complete association that contains one or more given rules.

In:= `MatchQ[<|a -> 1, b -> 2, c -> 3|>, KeyValuePattern[b -> _]]`
Out= In:= `MatchQ[<|a -> 1, b -> 2, c -> 3|>, KeyValuePattern[{c -> _, a -> _}]]`
Out= Compute data on the gravitational field at several points of the Earth.

In:= ```points = {{40, -100, 691}, {30, -120, 560}, {80, 70, 91}}; data = GeogravityModelData /@ points```
Out= Select the cases for which the field magnitude is larger than the standard average value.

In:= ```Cases[data, KeyValuePattern[ "Magnitude" -> _?(GreaterThan[ Quantity[1, "StandardAccelerationOfGravity"]])]]```
Out= Use KeyValueMap to further process each key-value pair.

In:= ```Cases[data, KeyValuePattern[ "Magnitude" -> _?(GreaterThan[ Quantity[1, "StandardAccelerationOfGravity"]])]]; KeyValueMap[ EntityProperty["GeogravityModel", #1] -> UnitConvert[#2, "Imperial"] &, First[%]]```
Out= 