If I have a vector {1,2,3}, I want to write an If statement, where if one of the positions is "1", it will perform a certain command.
test = {1, 2, 3}
# == 1 & /@ test
If[# == 1 & /@ test == True, Print["Yes"], Print["no"]]
I get this as the output:
If[{True, False, False} == True, Print["Yes"], Print["no"]]
What am I doing wrong? I am new to Mathematica.
MemberQ
to test if an element is in the list. $\endgroup$ – Szabolcs Apr 29 '14 at 18:31