Unique elements
There's a function in Clojure called distinct
that removes duplicates from a sequence. Your task is to write a function called uniques
that removes elements that appear twice.
Examples
(uniques []) ;=> ()
(uniques [1 2 3]) ;=> (1 2 3)
(uniques [1 1 2 3]) ;=> (2 3)
(uniques [1 2 3 1 2 3]) ;=> ()
(uniques [1 2 3 2]) ;=> (1 3)
Thanks to this site for the challenge idea where it is considered Medium in Python. The problem has been modified from the original.
Please submit your solutions as comments on this gist.
To subscribe: https://purelyfunctional.tv/newsletter/
@mchampine I initially had the same question, but then I took my cue from the name
uniques
to mean removing all elements which appear at least twice, i.e. retain elements which appear exactly once. When phrased like that, I think my answer is a fairly direct implementation, which chimes with the theme of this week's newsletter!