为什么这不起作用?无法弄清楚这一点。似乎与字符串的匹配方式有关。
我不断收到错误 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".
最佳答案
string 的元素是 char 类型,而不是 string。
to_rna_nucleotide($G) -> $C;
to_rna_nucleotide($C) -> $G;
to_rna_nucleotide($T) -> $A;
to_rna_nucleotide($A) -> $U.
关于erlang - 错误函数子句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35884533/