make a short pattern to match list which contains integers and symbols [duplicate]

I failed to make a short pattern to match {1,b,a,4,g}.

my code is as shown below:

MatchQ[{1, a, 3, b, c, 5, 6},
t_List /; MemberQ[t, _Integer | _Symbol]]


I guess there could be more clever way to make this pattern, such as using | and & .

MatchQ[{1, a, 3, b, c, 5, 6}, {(_Integer | _Symbol) ..}]

• thank you soooo much, this is exactly what i want ! PS: Could you please recommend me some higher-level books about mathematica ? – Oliver Redman Nov 28 '16 at 11:58
• @OliverRedman There isn't any book about mma I've read, I have learned mstly from here or sources/people linked to this forum. Here is something you can use: Where can I find examples of good Mathematica programming practice? – Kuba Nov 28 '16 at 12:12
data = {1, a, 3, b, c, 5, 6};

targets = {1, b, a, 4, g};

Intersection[data, targets]

(*  {1, a, b}  *)

Cases[data, Alternatives @@ targets]

(*  {1, a, b}  *)

Cases[targets, Alternatives @@ data]

(*  {1, b, a}  *)

Select[data, MemberQ[targets, #] &]

(*  {1, a, b}  *)

Select[targets, MemberQ[data, #] &]

(*  {1, b, a}  *)

Cases[data, _?(MemberQ[targets, #] &)]

(*  {1, a, b}  *)

Cases[targets, _?(MemberQ[data, #] &)]

(*  {1, b, a}  *)

DeleteCases[data, _?(FreeQ[targets, #] &)]

(*  {1, a, b}  *)

DeleteCases[targets, _?(FreeQ[data, #] &)]

(*  {1, b, a}  *)