Difficulty: Easy
Topics: seqs
Write a function which removes consecutive duplicates from a sequence.
(= (apply str (__ "Leeeeeerrroyyy")) "Leroy")
(= (__ [1 1 2 3 3 2 2 3]) '(1 2 3 2 3))
(= (__ [[1 2] [1 2] [3 4] [1 2]]) '([1 2] [3 4] [1 2]))
(fn compress-seq [dup-seq]
(let [first-item (first dup-seq)
rest-items (rest dup-seq)]
(cond
(nil? first-item) []
(= first-item (first rest-items)) (compress-seq rest-items)
:default (concat [first-item] (compress-seq rest-items)))))