hi,
it's not too mutch to ask. in fact i'm relay glad to explain some code, 'cause it shows, that you are willing to learn. so here it comes:

### my recursive subroutine ########################### sub enum { ### return the list of elements (aka nucleotides) if this is the l +ast ### recursion. ### also note that --$_[0] decrements the counter _before_ it is t +ested ################################################################## +##### return @{$_[1]} unless --$_[0]; ### define a variable which holds my return values ################################################## my @return; ### iterate over the return values of the next recursion ######################################################## for ( enum( $_[0], $_[1] ) ){ my $nuc = $_; ### iterate over all nucleotides ################################ for ( @{$_[1]} ) { push @return, $nuc . $_; } } ### return the list so far to the prior recursion ################################################# return @return; }

if you have problems to understand how it works, try to think about what happens, when $_[0] = 1 then think about what happens, when $_[0] = 2 and then you should get it.
if you don't understand this at all, it could be because my english is not even close to perfect. so maybe i just didn't explain it correct, which means "don't hesitate to ask questions" :-)

In reply to Re^3: Trying to construct all possible strings from 4 bases [ATCG] by Taulmarill
in thread Trying to construct all possible strings from 4 bases [ATCG] by monkfan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.