Bug introduced in 9.0 and fixed in 10.0.0
It is not surprising that DeleteDuplicates[{5,5.}]
returns {5,5.}
because DeleteDuplicates
uses SameQ
by default, and SameQ[5,5.]
is False
.
However, Equal[5,5.]
is True
, but DeleteDuplicates[{5,5.},Equal]
still returns {5,5.}
.
It is interesting to note that Union
works properly, in that Union[{5,5.},SameTest->Equal]
returns {5}
, as expected.
Is this a bug, or am I missing something? I'm using version 9.
Update:
I realize that using the function #1==#2&
will get it working, thanks for pointing this out.
However, my question really is "Is this a bug, or am I missing something?".
To illustrate this further, consider the following:
f[x__]:=Equal[x]
DeleteDuplicates[{5,5.},f]
(* {5} *)
In what capacity are f
and Equal
different? Or what is leading DeleteDuplicates
to treat them differently? They both take an arbitrary number of inputs, which is what I originally thought was the problem.