Skip to content

Commit

Permalink
Merge pull request #108 from justCxx/remove-duplicates
Browse files Browse the repository at this point in the history
Update remove duplicates issue
  • Loading branch information
mokevnin committed Sep 8, 2015
2 parents aa69112 + 7cdec30 commit 32ec384
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions test/battle_solutions/remove_duplicates_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
[battle-asserts.test-helper :refer [assert-equal]]))

(defn compress [seq]
(cond
(nil? seq) nil
(nil? (second seq)) seq
(= (first seq)
(first (rest seq))) (compress (rest seq))
:else (cons (first seq)
(compress (rest seq)))))
(->> seq
(reduce #(cond
(= %2 (first %1)) %1
:else (conj %1 %2))
nil)
(reverse)))

(deftest test-asserts
(assert-equal [] (compress []))
Expand Down

0 comments on commit 32ec384

Please sign in to comment.