Created
November 15, 2013 17:41
-
-
Save rsslldnphy/7488440 to your computer and use it in GitHub Desktop.
Haskell RNA transcription!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Short version to show the power of Haskell :-) | |
module DNA(toRNA) where | |
toRNA = map convert where | |
convert 'T' = 'U' | |
convert n = n | |
-- Long version with a bunch of cool stuff that makes me happy | |
module DNA(toRNA) where | |
type Nucleotide = Char | |
type DNA = [Nucleotide] | |
type RNA = [Nucleotide] | |
toRNA :: DNA -> RNA | |
toRNA = map (thymidine `to` uracil) | |
thymidine :: Nucleotide | |
thymidine = 'T' | |
uracil :: Nucleotide | |
uracil = 'U' | |
to :: Nucleotide -> Nucleotide -> Nucleotide -> Nucleotide | |
to x y n | |
| n == x = y | |
| otherwise = n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment