Search code examples
vectorclojureequality

Equality of vectors in clojure


I was trying to solve this problem

and I realized that this statement gave output as false.

(= (#(into [] (distinct %)) [1 2 3]) 
   '(1 1 2 2 3 3))

It is supposed to be true as the function is also returning the same vector.

Can someone please explain to me why this is false?


Solution

  • From the comments, I found out that I was using the distinct method incorrectly and hence decided to use the repeat method to get the answer which was:

    mapcat #(repeat 2 %)