Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re3: Genetic Code

by dragonchild (Archbishop)
on Aug 18, 2003 at 20:24 UTC ( [id://284711]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Genetic Code
in thread Genetic Code

%: Modolus operator. If $a % $b, returns the remainder when $a is divided by $b. Thus, 45 % 6 is 3, as is 51 % 6.

The code in question does this:

my $fmt = $FMT_DNA[$i++ % @FMT_DNA];
  1. Get the remainder when $i is divided by the number of elements in @FMT_DNA and put it in a temp variable.
  2. Increment $i by 1.
  3. Get the element in @FMT_DNA with an index of the temp variable and put it in $fmt.

What this is doing is treating @FMT_DNA as a circular list - a list that will wrap around to the beginning when it runs out of elements. So, if it was 3 elements, it would do element 0, element 1, element 2, element 0, element 1, etc.

------
We are the carpenters and bricklayers of the Information Age.

The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://284711]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-25 23:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found