0

Consider the following matching:

p = Rule[_String, _String];
MatchQ[f[Rule["a", "b"], Rule["c", "d"]], f[p ..]]
(* True *)

If you replace f with List (or even outlandish operators like Grid or SingularValueDecomposition), it still matches:

MatchQ[List[Rule["a", "b"], Rule["c", "d"]], List[p ..]]
(* True *)

However, if you replace f with Association, it doesn't match:

MatchQ[Association[Rule["a", "b"], Rule["c", "d"]], Association[p ..]]
(* False *)

Why is this? Ordinarily I would suspect that evaluation changes the form, but calling FullForm[Association[Rule["a", "b"], Rule["c", "d"]]] returns Association[Rule["a", "b"], Rule["c", "d"]], ie, its form is unchanged.

Ultimately I'd like a pattern that matches Associations of Strings to TemporalDatas, and while trying to figure out why my pattern didn't work, I found the above minimal(ish) example.

Peter Richter
  • 353
  • 1
  • 5

0 Answers0