linked icon indicating copy to clipboard operation
linked copied to clipboard

Map equality should respect insertion order

Open metametadata opened this issue 1 year ago • 0 comments

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)))

metametadata avatar Jul 12 '24 11:07 metametadata