Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

The minor bug is that this statement:

$position[0] == @list ? $done = 1 : $next = 1;
never sets the $done flag. I think you meant:

@position == @list ? $done = 1 : $next = 1;
And because $done is never set,

return () if $done;
never executes. It's a truly minor bug though, because you have another bit of code that detects the end condition:

return () if $by > @list;
So I just removed $done entirely. (Actually, looking at my code, when I was rearranging, I removed that last condition. I should've kept it because my code tests for the end condition on every call, where your terminator checks only when it's time to go to the next size of results. I'll update my node to reflect that.)

The other thing I did was remove $end_pos since its value has such a limited lifetime, and add a passel of comments so I wouldn't forget how it works!

Now off to How A Function Becomes Higher Order and yer iterator toot!


In reply to Re^5: Finding all Combinations by roboticus
in thread Finding all Combinations by narse

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (8)
    As of 2015-11-25 22:24 GMT
    Find Nodes?
      Voting Booth?

      What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

      Results (692 votes), past polls