Hi, Cyrex.
zipmap
makes a Map, which is an unordered collection. So you are not guaranteed to get the pairs out in the same order you put them in. You may, depending on the clojure version, the exact keys, and the size of the input, but this is just a lucky coincidence. Look what happens if you pass in longer vectors (clojure 1.8.0):
(def v (shuffle (range 10)) ;;=>
[5 6 2 4 0 3 7 8 9 1]
(def w (shuffle (range 10)) ;;=>
[0 5 6 2 3 8 1 4 7 9]
(zipmap v w) ;;=> unordered
{0 3, 7 1, 1 9, 4 2, 6 5, 3 8, 2 6, 9 7, 5 0, 8 4}
(seq (zipmap v w)) ;;=> random order out
([0 3] [7 1] [1 9] [4 2] [6 5] [3 8] [2 6] [9 7] [5 0] [8 4])
Also, be aware that flatten
acts recursively, so it may pass the tests, but fail more generally:
(f [:a :b] [[1 2] [3 4]]) ;;=>
([:a [1 2]] [:b [3 4]])
(flatten '([:a [1 2]] [:b [3 4]])) ;;=>
(:a 1 2 :b 3 4) ;; Wrong
Hope that helps,
Leif