I don't think this line does what you think it does:
my @a does DNA = 'GAATCC';
It is the same as:
my @a := [ 'GAATCC', ];
@a does DNA;
Basically the .comb
call coerces the array into a Str, and splits that into characters.
If you instead did this:
my @a = 'GAATCC' but DNA;
Which is basically the same as
my @a := Seq.new(('GAATCC' but DNA).iterator).Array;
Note that @
variables store Positional
values not Iterable
values.
The thing you want is
my $a = 'GAATCC' but DNA;
$a.map: &say;
If you want to be able to use for
you can't use a variable with a $
sigil
my a = 'GAATCC' but DNA;
.say for a;
You may want to add Seq
list
List
etc methods to DNA
.
role DNA does Iterable {
method iterator(){
self.comb.iterator
}
method Seq(){
Seq.new: self.iterator
}
method list(){
# self.Seq.list
List.from-iterator: self.iterator
}
}
my $a = 'GAATCC' but DNA;
.say for @$a;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…