AI-Gene-Sequence
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
AI/Gene/Sequence.pm view on Meta::CPAN
It is intended that the methods in this code are inherited
by other modules.
=head2 Anatomy of a gene
A gene is a sequence of tokens, each a member of some group
of simillar tokens (they can of course all be members of a
single group). This module encodes genes as a string
representing token types, and an array containing the
tokens themselves, this allows for arbitary data to be
stored as a token in a gene.
For instance, a regular expression could be encoded as:
$self = ['ccartm',['a', 'b', '|', '[A-Z]', '\W', '*?'] ]
Using a string to indicate the sort of thing held at the
corresponding part of the gene allows for a simple test
of the validity of a proposed gene by using a regular
expression.
MANIFEST
AI/Gene/Sequence.pm
AI/Gene/Simple.pm
demo/Regexgene.pm
demo/Musicgene.pm
demo/spamscan.pl
demo/music.pl
t/tgene.t
t/tsimp.t
test.pl
META.yml Module meta-data (added by MakeMaker)
demo/Regexgene.pm view on Meta::CPAN
$gene->[0] = $new;
push @{$gene->[1]}, $token[1];
}
return $gene;
}
=head2 clone
As we are going to allow nested sequences, then we need to make sure that
when we copy an object we create new versions of everthing, rather than
reusing pointers to data used by other objects.
=cut
sub clone {
my $self = shift;
my $new = bless [$self->[0], [], $self->[2]], ref($self);
@{$new->[1]} = map {ref($_) ? $_->clone : $_} @{$self->[1]}; # woohoo, recursive objects
return $new;
}
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.188 second using v1.00-cache-2.02-grep-82fe00e-cpan-4673cadbf75 )