rna_transcription.erl

1
2
3
4
5
6
7
8
9
10
11
12
-module(rna_transcription).
-export([to_rna/1]).

to_rna(Sequence) ->
  [
   case Nuc of
     $G -> $C;
     $C -> $G;
     $T -> $A;
     $A -> $U
   end || Nuc <- Sequence
  ].

Comments

I wanted to do a wildcard case here too so it'd silently ignore invalid chars. I couldn't figure out how to add nothing to the string in that case. i.e. something like

1
2
$A -> $U;
_ -> ''

without turning the whole thing into a list of integers rather than a nice string.

But maybe it's fine this way, and maybe it fits better with a let-it-crash philosophy!

helenst commented 18 March 2016 at 14:57 UTC

You're not logged in right now. Please login via GitHub to comment