Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 3
    $\begingroup$ {a} /. _ -> "who said it works only at the first level?" and {} != 3 vs {} =!= 3. $\endgroup$ Commented Jan 23, 2019 at 14:37
  • $\begingroup$ @Kuba, thank you for your reply. However, I do not fully understand. Apparently in the UnsameQ[] case, the entire {-7,3,2} is becoming x (/after/ the first level?) and not the same as 3. Why does that not continue with Unequal[]? (For that matter, I am a tad stymied why {}!=3 does not return False.) $\endgroup$ Commented Jan 23, 2019 at 15:26
  • $\begingroup$ ! SameQ[] would be {-7, 3, 2} /. x_ /; ! (x === 3) -> w, which returns the same as UnsameQ[]. But ! Equal[] is different than UnsameQ[], as your 2nd and 4th examples show. $\endgroup$ Commented Jan 23, 2019 at 21:00
  • $\begingroup$ Perhaps you want Replace[list, x_ /; x =!= 3 -> w, 1] or Replace[list, x_ /; x =!= 3 -> w, Infinity] $\endgroup$ Commented Jan 23, 2019 at 21:01
  • $\begingroup$ @Michael E2, thank you for your reply. Yes, I also played with !SameQ[]. I see that !Equal[] and UnsameQ[] are different, my questions are: why? and why should I have known that? Also, I would appreciate a pointer to some documentation, explaining why {}!=3 does not return False. Thank you. $\endgroup$ Commented Jan 24, 2019 at 13:23