Skip to content

Instantly share code, notes, and snippets.

@rsslldnphy
Created November 15, 2013 17:41
Show Gist options
  • Save rsslldnphy/7488440 to your computer and use it in GitHub Desktop.
Save rsslldnphy/7488440 to your computer and use it in GitHub Desktop.
Haskell RNA transcription!
-- 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