孟德尔第一定律
作者:L. Grondin
http://rosalind.info/problems/iprb/
示例输入
2 2 2
示例输出
0.78333
源代码: iprb-grondilu.pl
use v6;
sub take-two($n) { $n*($n-1)/2 }
sub MAIN(Str $input = "2 2 2") {
given $input.split: " " {
say
take-two([+] .[].cache) R/ (
[+]
take-two(.[0]) , # two homozygous dominant
3/4 * take-two(.[1]) , # two heterozygous
.[0] * .[1] , # one homozygous dominant and one heterozygous
.[0] * .[2] , # one homozygous dominant and one homozygous recessive
1/2 * .[1] * .[2] , # one heterozygous and one homozygous recessive
)
}
}
Perl 6 示例