The minor bug is that this statement:
$position == @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!
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- 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
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] |