From fb48f38fb4dfa2b3bce63c8a7072004458cfdeac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20B=20Nagy?= <20251272+BNAndras@users.noreply.github.com> Date: Thu, 16 May 2024 08:58:03 -0700 Subject: [PATCH] Rename nucleotide-count files (#241) --- .../nucleotide-count/.meta/config.json | 4 +-- .../nucleotide-count/.meta/example.lfe | 9 +++-- .../practice/nucleotide-count/src/dna.lfe | 0 .../src/nucleotide-count.app.src | 2 +- .../nucleotide-count/src/nucleotide-count.lfe | 4 +++ .../nucleotide-count/test/dna-tests.lfe | 34 ------------------- .../test/nucleotide-count-tests.lfe | 25 ++++++++++++++ 7 files changed, 36 insertions(+), 42 deletions(-) delete mode 100644 exercises/practice/nucleotide-count/src/dna.lfe create mode 100644 exercises/practice/nucleotide-count/src/nucleotide-count.lfe delete mode 100644 exercises/practice/nucleotide-count/test/dna-tests.lfe create mode 100644 exercises/practice/nucleotide-count/test/nucleotide-count-tests.lfe diff --git a/exercises/practice/nucleotide-count/.meta/config.json b/exercises/practice/nucleotide-count/.meta/config.json index 0be7ad20..e07dd350 100644 --- a/exercises/practice/nucleotide-count/.meta/config.json +++ b/exercises/practice/nucleotide-count/.meta/config.json @@ -11,10 +11,10 @@ ], "files": { "solution": [ - "src/dna.lfe" + "src/nucleotide-count.lfe" ], "test": [ - "test/dna-tests.lfe" + "test/nucleotide-count-tests.lfe" ], "example": [ ".meta/example.lfe" diff --git a/exercises/practice/nucleotide-count/.meta/example.lfe b/exercises/practice/nucleotide-count/.meta/example.lfe index be5351b0..4051fc5b 100644 --- a/exercises/practice/nucleotide-count/.meta/example.lfe +++ b/exercises/practice/nucleotide-count/.meta/example.lfe @@ -1,6 +1,5 @@ -(defmodule dna - (export (count 2) - (nucleotide-counts 1))) +(defmodule nucleotide-count + (export (counts 1))) (defun validate (nucleotide) (if (lists:member nucleotide '("A" "C" "G" "T")) @@ -8,7 +7,7 @@ (erlang:error (++ "Invalid nucleotide: '" nucleotide "'")))) (defun count (strand nucleotide) - ;; `validate` will throw iff `nucleotide` is invalid. + ;; `validate` will throw if `nucleotide` is invalid. (validate nucleotide) (lists:foldl (lambda (nucleotide* sum) @@ -18,7 +17,7 @@ 0 strand)) -(defun nucleotide-counts (strand) +(defun counts (strand) (lists:map (lambda (nucleotide) `#(,nucleotide ,(count strand nucleotide))) diff --git a/exercises/practice/nucleotide-count/src/dna.lfe b/exercises/practice/nucleotide-count/src/dna.lfe deleted file mode 100644 index e69de29b..00000000 diff --git a/exercises/practice/nucleotide-count/src/nucleotide-count.app.src b/exercises/practice/nucleotide-count/src/nucleotide-count.app.src index 4b4932bd..55a13846 100644 --- a/exercises/practice/nucleotide-count/src/nucleotide-count.app.src +++ b/exercises/practice/nucleotide-count/src/nucleotide-count.app.src @@ -3,7 +3,7 @@ [{description, ""}, {vsn, "0.0.1"}, {modules, - ['dna']}, + ['nucleotide-count']}, {registered, []}, {applications, [kernel, stdlib]}, diff --git a/exercises/practice/nucleotide-count/src/nucleotide-count.lfe b/exercises/practice/nucleotide-count/src/nucleotide-count.lfe new file mode 100644 index 00000000..286bb52e --- /dev/null +++ b/exercises/practice/nucleotide-count/src/nucleotide-count.lfe @@ -0,0 +1,4 @@ +(defmodule nucleotide-count + (export (counts 1))) + + ; Please implement the counts function diff --git a/exercises/practice/nucleotide-count/test/dna-tests.lfe b/exercises/practice/nucleotide-count/test/dna-tests.lfe deleted file mode 100644 index 15c20677..00000000 --- a/exercises/practice/nucleotide-count/test/dna-tests.lfe +++ /dev/null @@ -1,34 +0,0 @@ -(defmodule dna-tests - (behaviour ltest-unit) - (export all)) - -(include-lib "ltest/include/ltest-macros.lfe") - -(deftest empty-dna-sting-has-no-adenine - (is-equal 0 (dna:count "" "A"))) - -(deftest repetitive-cytosine-gets-counted - (is-equal 5 (dna:count "CCCCC" "C"))) - -(deftest counts-only-thymine - (is-equal 1 (dna:count "GGGGGTAACCCGG" "T"))) - -(deftest validates-nucleotides - (is-error _ (dna:count "GACT" "X"))) - -(deftest validates-strand - (is-error _ (dna:count "GACYT" "G"))) - -(deftest empty-dna-string-has-no-nucleotides - (is-equal `(#("A" 0) #("C" 0) #("G" 0) #("T" 0)) - (dna:nucleotide-counts ""))) - -(deftest repetitive-sequence-has-only-guanine - (is-equal `(#("A" 0) #("C" 0) #("G" 8) #("T" 0)) - (dna:nucleotide-counts "GGGGGGGG"))) - -(deftest counts-all-nucleotides - (is-equal - `(#("A" 20) #("C" 12) #("G" 17) #("T" 21)) - (dna:nucleotide-counts - "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC"))) diff --git a/exercises/practice/nucleotide-count/test/nucleotide-count-tests.lfe b/exercises/practice/nucleotide-count/test/nucleotide-count-tests.lfe new file mode 100644 index 00000000..6436ea0e --- /dev/null +++ b/exercises/practice/nucleotide-count/test/nucleotide-count-tests.lfe @@ -0,0 +1,25 @@ +(defmodule nucleotide-count-tests + (behaviour ltest-unit) + (export all)) + +(include-lib "ltest/include/ltest-macros.lfe") + +(deftest empty-strand + (is-equal `(#("A" 0) #("C" 0) #("G" 0) #("T" 0)) + (nucleotide-count:counts ""))) + +(deftest can-count-one-nucleotide-in-single-character-input + (is-equal `(#("A" 0) #("C" 0) #("G" 1) #("T" 0)) + (nucleotide-count:counts "G"))) + +(deftest strand-with-repeated-nucleotide + (is-equal `(#("A" 0) #("C" 0) #("G" 7) #("T" 0)) + (nucleotide-count:counts "GGGGGGG"))) + +(deftest strand-with-multiple-nucleotides + (is-equal `(#("A" 20) #("C" 12) #("G" 17) #("T" 21)) + (nucleotide-count:counts "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC"))) + +(deftest strand-with-invalid-nucleotides + (is-error (nucleotide-count:counts "AGXXACT"))) +