1

It is a very simple problem but I am confused. A comment is required. I have the following list

masters={C18[1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0], 
 C18[1, 1, 1, 1, 1, 1, 0, 1, 1, 2, 0, 0]}

Now if I write

If [C18[1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0] == masters[[2]], 
 Print["Yes"], Print["No"]]

It should give No , but it is giving

If[C18[1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0] == 
  C18[1, 1, 1, 1, 1, 1, 0, 1, 1, 2, 0, 0], Print["Yes"], Print["No"]]

Where is the problem?

Tanmoy Pati
  • 345
  • 1
  • 7

1 Answers1

7
masters = {C18[1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0], 
   C18[1, 1, 1, 1, 1, 1, 0, 1, 1, 2, 0, 0]};

C18 is an undefined function. Since neither expression evaluates, it is unknown whether the expressions are Equal

If[C18[1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0] == masters[[2]], Print["Yes"], 
 Print["No"], Print["Unknown"]]

(* Unknown *)

Use SameQ to check whether the unevaluated expressions are identical.

If[C18[1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0] === masters[[2]], Print["Yes"], 
 Print["No"], Print["Unknown"]]

(* No *)

Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198