Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • If you asume that any block got FIRST and LAST but by default those fellows are empty function calls, you could move the condition to call FIRST and/or LAST out of the pointy block and into for.

    The only condition you have left then would be if the list is empty. "for" has to check that anyway (at some point) so you don't really add anything.

    I don't really like to have $LOOP_HAS_RUN = True; any time you call the pointy block.

    I tried to implement it in javascript and ended up with the following.

    • Your solution works fine when the FIRST and LAST does not access any lexical variables specific to the loop block. $a in your Perl 6 code at the end is such a variable. Sending $code_first and $code_last in as unrelated closures doesn't give those closures access to $a.

      For a solution that does work for these cases, please re-read the blog post. :)