cosmologicon / pywat

Python wats

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

All NaNs are unequal, but some are more unequal than others

cdyson37 opened this issue · comments

Suggestion for a wat:

nan = float("nan")
print (nan == nan)                      # False
print ({1 : nan} == {1 : nan})          # True
print ({1 : nan} == {1 : float("nan")}) # False

That's great. Looks like it works for lists too. I added it to the section on NaN-related wats. Thanks!

I love it! Could possibly provide a hint as to why we have this behaviour by pointing out that "x is x" but "x != x" (and it's the internal assumption that the former implies the latter that's the problem). But that might detract from the beauty of the wat :)
EDIT: You did that already in explanation.md - ignore me!