Reputation: 91
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?
Upvotes: 0
Views: 123
Reputation: 13473
The question you ask is irrelevant to the problem you refer to, which your own answer solves. Looking at the question alone ...
distinct
to the wrong
sequence.=
to any two sequences. You don't have
to convert the lazy sequence that distinct
produces to a vector.Thus the following suffices ...
(= [1 2 3] (distinct '(1 1 2 2 3 3)))
=> true
Upvotes: 1
Reputation: 91
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 %)
Upvotes: 0