<|a -> 2, b -> 3|> == <|b -> 3, a -> 2|>
returns False
; can anybody explain why? If I am not mistaken here these two associations would be identical from the practical point of view.
Perhaps as Pickett describes the developers do not consider these associations Equal
since that function performs other conversions like:
Quantity[5, "Percent"] == 0.05
True
But perhaps Equal
has not been (properly?) extended to associations yet as 2.0
and 2
are Equal
but these are not:
<|a -> 2|> == <|a -> 2.0|>
False
Depending on what you are doing this might be useful, but beware it does not have early exit (short-circuit) behavior:
eq[{x_}] = False;
eq[{x__}] := Equal[x]
one = <|a -> 2, b -> 3|>;
two = <|b -> 3, a -> 2.0|>;
And @@ Merge[{one, two}, eq]
True
-
$\begingroup$ Thanks a lot for this detailed investigation of the fact. I think that
<|a -> 2|> == <|a -> 2.0|>
beingFalse
points towards a bug, rather than a feature. $\endgroup$ – Rho Phi Jun 2 '15 at 9:05
a->something
many times you might not realizing that later you are overwriting your assignment, but isn't it the same for variable assignment with=
? I meana=2; b=3; a=something
is the same as<| a->2, b->3, a->something |>
... right? $\endgroup$ – Rho Phi Jun 2 '15 at 9:08Association
that does not care about order:Data`UnorderedAssociation
. $\endgroup$ – Stefan R Jun 3 '15 at 19:26