Skip to content

Instantly share code, notes, and snippets.

@boddhisattva
Created October 24, 2018 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boddhisattva/96b4e9f21018cf6250d30e8c1c06d753 to your computer and use it in GitHub Desktop.
Save boddhisattva/96b4e9f21018cf6250d30e8c1c06d753 to your computer and use it in GitHub Desktop.
RNA v2 solution
defmodule RNATranscription do
@guanine ?G
@adenine ?A
@cystosine ?C
@uracil ?U
@thymine ?T
@doc """
Transcribes a character list representing DNA nucleotides to RNA
## Examples
iex> RNATranscription.to_rna('ACTG')
'UGAC'
"""
@spec to_rna([char]) :: [char]
def to_rna(dna) do
Enum.map(dna, fn dna_char ->
case dna_char do
@guanine -> @cystosine
@cystosine -> @guanine
@thymine -> @adenine
@adenine -> @uracil
end
end)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment