(mapset inc [1 1 2 2])
;=> #{2 3}
Answer:
(defn mapset [fn elements]
(let [uniq (into #{} elements)]
(set (map fn uniq))))
How can I write a piece of code without a unit test?
(deftest mapset-test
(is (= #{ 2 3 } (mapset inc [1 1 2 2]))))
Invoking mapset:
(mapset inc [1 1 2 2])
;=> #{3 2}
No comments:
Post a Comment