linked
linked copied to clipboard
Map equality should respect insertion order
Insertion order is a crucial property of the data structure and it's counterintuitive that on equality the order is not respected. It has bit me several times when I was writing unit tests for my code.
Steps
Evaluate:
(= (linked/map 1 2
3 4)
(linked/map 3 4
1 2))
Expected
false.
Actual
true.
Workaround
Convert linked maps to seqs prior to comparison:
(= (seq (linked/map 1 2
3 4))
(seq (linked/map 3 4
1 2)))