0
$\begingroup$

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?

$\endgroup$

1 Answer 1

8
$\begingroup$
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 *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.