Reputation: 61121
Why is this not working? Can't figure this out. Seems to be something with the way strings are matched.
I keep getting an error error:function_clause
.
-module(rna_transcription).
-export([to_rna/1, to_rna_nucleotide/1]).
to_rna(DNA) -> lists:map(fun to_rna_nucleotide/1, DNA).
to_rna_nucleotide("G") -> "C";
to_rna_nucleotide("C") -> "G";
to_rna_nucleotide("T") -> "A";
to_rna_nucleotide("A") -> "U".
Upvotes: 6
Views: 3279
Reputation:
The element of string is of type char, not string.
to_rna_nucleotide($G) -> $C;
to_rna_nucleotide($C) -> $G;
to_rna_nucleotide($T) -> $A;
to_rna_nucleotide($A) -> $U.
Upvotes: 5