Skip to content

Commit

Permalink
exercism#1310 haskell rna-transcription now matches README
Browse files Browse the repository at this point in the history
  • Loading branch information
etrepum authored and fluxusfrequency committed Mar 24, 2014
1 parent 52862ff commit 7c9a949
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
8 changes: 6 additions & 2 deletions assignments/haskell/rna-transcription/example.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
module DNA (toRNA) where

replaceThymidine :: Char -> Char
replaceThymidine 'T' = 'U'
replaceThymidine nucleotide = nucleotide
replaceThymidine c = case c of
'C' -> 'G'
'G' -> 'C'
'A' -> 'U'
'T' -> 'A'
_ -> error $ "Invalid nucleotide " ++ show c

toRNA :: String -> String
toRNA = map replaceThymidine
20 changes: 10 additions & 10 deletions assignments/haskell/rna-transcription/rna-transcription_test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ testCase label assertion = TestLabel label (TestCase assertion)

toRNATests :: [Test]
toRNATests =
[ testCase "transcribes cytidine unchanged" $
"C" @=? toRNA "C"
, testCase "transcribes guanosine unchanged" $
"G" @=? toRNA "G"
, testCase "transcribes adenosine unchanged" $
"A" @=? toRNA "A"
, testCase "transcribes thymidine to uracil" $
"U" @=? toRNA "T"
, testCase "transcribes all occurrences of thymidine to uracil" $
"ACGUGGUCUUAA" @=? toRNA "ACGTGGTCTTAA"
[ testCase "transcribes cytidine to guanosine" $
"G" @=? toRNA "C"
, testCase "transcribes guanosine to cytidine" $
"C" @=? toRNA "G"
, testCase "transcribes adenosine to uracil" $
"U" @=? toRNA "A"
, testCase "transcribes thymidine to adenosine" $
"A" @=? toRNA "T"
, testCase "transcribes all ACGT to UGCA" $
"UGCACCAGAAUU" @=? toRNA "ACGTGGTCTTAA"
]

main :: IO ()
Expand Down

0 comments on commit 7c9a949

Please sign in to comment.