From d81fdc52e6f29a66e2af9f41d54acc3028415eb0 Mon Sep 17 00:00:00 2001 From: Simon Jakobi Date: Sun, 17 Aug 2014 12:47:45 +0200 Subject: [PATCH] nucleotide-count: Remove special treatment of uracil For the related discussion see https://github.com/exercism/xpython/pull/98. This also changes the namespace of the example solution from "dna" to "nucleotide_count". --- nucleotide-count/example.clj | 9 ++++----- nucleotide-count/nucleotide_count_test.clj | 3 --- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/nucleotide-count/example.clj b/nucleotide-count/example.clj index a477a6578..8241cad17 100644 --- a/nucleotide-count/example.clj +++ b/nucleotide-count/example.clj @@ -2,7 +2,6 @@ (:refer-clojure :exclude [count])) (def ^{:private :const} dna-nucleotide? #{\A \C \G \T}) -(def ^{:private :const} rna-nucleotide? #{\A \C \G \U}) (def ^{:private :const} base-count (apply hash-map (interleave dna-nucleotide? (repeat 0)))) @@ -15,7 +14,7 @@ (defn count "count occurrences of nucleotide in strand" [nucleotide strand] - (cond - (dna-nucleotide? nucleotide) ((nucleotide-counts strand) nucleotide) - (rna-nucleotide? nucleotide) 0 - :else (throw (Exception. (str "invalid nucleotide '" nucleotide "'"))))) + (if + (dna-nucleotide? nucleotide) + ((nucleotide-counts strand) nucleotide) + (throw (Exception. (str "invalid nucleotide '" nucleotide "'"))))) diff --git a/nucleotide-count/nucleotide_count_test.clj b/nucleotide-count/nucleotide_count_test.clj index bcd0f0f9a..303d69c2e 100644 --- a/nucleotide-count/nucleotide_count_test.clj +++ b/nucleotide-count/nucleotide_count_test.clj @@ -20,9 +20,6 @@ (deftest counts-only-thymidine (is (= 1 (nucleotide-count/count \T "GGGGGTAACCCGG")))) -(deftest dna-has-no-uracil - (is (= 0 (nucleotide-count/count \U "GATTACA")))) - (deftest validates-nucleotides (is (thrown-with-msg? Exception #"invalid nucleotide" (nucleotide-count/count \X "GACT"))))