The following transcript shows what happens inside map!
. The functions first
and rest
are called on the same object, but depending on the current order of the object it will return the values in different orders, which can result in sometimes getting the same value twice. This is shown in line 262, 263, 268 and 269.
This will also happen in other places where first
and rest
are called on the same object.
I read this section in the documentation and could refer to the same situation. If this was intended to apply to this situation, perhaps this could be made more explicit?
An object can be iterated over as a sequence. The resulting sequence is guaranteed to have no duplicates, but is not guaranteed to return in any particular order.
Transcript:
user [255]> (let ([x {:x 1 :y 2}]) [(first x) (rest x)])
[255]= [(:x . 1) ((:y . 2))]
user [256]> (let ([x {:x 1 :y 2}]) [(first x) (rest x)])
[256]= [(:x . 1) ((:y . 2))]
user [257]> (let ([x {:x 1 :y 2}]) [(first x) (rest x)])
[257]= [(:x . 1) ((:y . 2))]
user [258]> (let ([x {:x 1 :y 2}]) [(first x) (rest x)])
[258]= [(:x . 1) ((:y . 2))]
user [259]> (let ([x {:x 1 :y 2}]) [(first x) (rest x)])
[259]= [(:x . 1) ((:y . 2))]
user [260]> (let ([x {:x 1 :y 2}]) [(first x) (rest x)])
[260]= [(:x . 1) ((:y . 2))]
user [261]> (let ([x {:x 1 :y 2}]) [(first x) (rest x)])
[261]= [(:x . 1) ((:y . 2))]
user [262]> (let ([x {:x 1 :y 2}]) [(first x) (rest x)])
[262]= [(:x . 1) ((:x . 1))]
user [263]> (let ([x {:x 1 :y 2}]) [(first x) (rest x)])
[263]= [(:y . 2) ((:y . 2))]
user [264]> (let ([x {:x 1 :y 2}]) [(first x) (rest x)])
[264]= [(:x . 1) ((:y . 2))]
user [265]> (let ([x {:x 1 :y 2}]) [(first x) (rest x)])
[265]= [(:y . 2) ((:x . 1))]
user [266]> (let ([x {:x 1 :y 2}]) [(first x) (rest x)])
[266]= [(:x . 1) ((:y . 2))]
user [267]> (let ([x {:x 1 :y 2}]) [(first x) (rest x)])
[267]= [(:y . 2) ((:x . 1))]
user [268]> (let ([x {:x 1 :y 2}]) [(first x) (rest x)])
[268]= [(:y . 2) ((:y . 2))]
user [269]> (let ([x {:x 1 :y 2}]) [(first x) (rest x)])
[269]= [(:x . 1) ((:x . 1))]