Error while generate DNA with uniform()
Salih Dincer
salihdb at hotmail.com
Sat Sep 3 21:18:10 UTC 2022
On Saturday, 3 September 2022 at 14:25:48 UTC, Steven
Schveighoffer wrote:
> [...] what you need anyway is a `char`, so just return a
> `char`. [...]
Clean-cut, thank you!
It's very clear to me...
```d
import std;
void main()
{
alias fp = char function() @system;
enum DNA : char
{
timin = 'T',
sitozin = 'C',
guanin = 'G',
adenin = 'A'
}
fp getDNA = () => uniform!"[]"(DNA.min,
DNA.max);
enum n = 30;
auto genes = generate!getDNA.take(n).array;
auto unique = genes.uniq.array;
// AAAACATCATGGTAGGCCTTTCATGCGCTA
assert(unique.length < n, "no repeat");
unique.writeln; // ACATCATGTAGCTCATGCGCTA
}
```
SDB at 79
More information about the Digitalmars-d-learn
mailing list