Created
October 24, 2018 10:19
-
-
Save boddhisattva/96b4e9f21018cf6250d30e8c1c06d753 to your computer and use it in GitHub Desktop.
RNA v2 solution
This file contains 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
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