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
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Suboptimal (Score:1)
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:
Re:Suboptimal (Score:1)
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
Reply to This
Parent