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.
  • The code is really hard to follow. It takes a lot of careful scanning and thinking to understand which cases will invoke which variant of the sub. At first I thought you hadn’t handled the case where a strike is followed by a spare.

    Also, the logic for how much to advance is confusingly written. A little extra work would make this 10× easier to read:

    subset Strike of Any where { $_ eq 'X' };
    subset Spare  of Any where { $_ eq '/' };
    subset  Some  of Any where { $_ ne 'X' & '/' };

    • Thanks for the subset suggestion. I'd tried putting "where" clauses inline, but that was very clunky. Subsets definitely solve that.

      I'm not sure, however, I like your version of the consumption logic any better than mine: using a modifier-op ("shift" in both the conditional and consequent confuses me (I like conditionals to be pure). I would tend to agree, though, that my form was equally confusing. It might be best to be explicit:

              my $bowls_this_frame = @scores[0] eq "X" ?? 1 !! 2;
              @scores.shift for ^$bowls_this_frame