ar0n has asked for the wisdom of the Perl Monks concerning the following question:
sub mutate() { my $self = shift; # my $strength = shift || 2; my($i, $p1, $p2, $c1, $c2); my $my_astr = $self->astr(); # Get $strength (2) positions and flip the characters $c1 = substr($my_astr, $p1 = int rand(length($my_astr)), 1); $c2 = substr($my_astr, $p2 = int rand(length($my_astr)), 1); substr($my_astr, $p1, 1, $c2); substr($my_astr, $p2, 1, $c1); return $self->astr($my_astr); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: character flipping
by cwest (Friar) on Jun 09, 2000 at 02:33 UTC | |
|
Re: character flipping
by lhoward (Vicar) on Jun 09, 2000 at 01:11 UTC | |
|
Re: character flipping
by eduardo (Curate) on Jun 09, 2000 at 02:35 UTC | |
by ar0n (Priest) on Jun 09, 2000 at 23:20 UTC |