Stories
Slash Boxes
Comments
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.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Great work. Here is the same code in different formats generated using Syntax::Highlight::Perl6 [cpan.org].

    HTML with tree viewer (needs JavaScript) [perl6.nl]

    Snippet HTML (No JavaScript) [perl6.nl]

    Note: i modified line 15 to be STD-parsable.

  • Nice script.

    You've liberated yourself from the parens in if statements and loops. Good work.

    Now liberate yourself from the parens around the rvalue in array assignments. my @a = 1,2,3; FTW.

  • Take this f.ex.:

    my @found;
    my @letters = $!word.split('');
    my $ord = $letter.ord;
    for 0..(@letters.elems - 1) -> $i {
        if @letters[$i].ord == $ord {
            @found.push($i);
        }
    }

    In Perl 6 you write this like so:

    my $ord = $letter.ord;
    my @found = map { .key }, grep { .value.ord == $ord }, $!word.split('').pairs;

    Although I don’t know why you don’t simply say this:

    my $l = $letter.substr(0,1);

    The resulting simplification should be obvious. Maybe yo

  • It's "Mississippi".

    Or as my momma taught me: "Eme eye crooked letter crooked letter eye crooked letter crooked letter eye humpback humpback eye".

  • I didn’t do so immediately because of the large amount of code, which seemed somewhat shocking for something like Hangman. Now that I have read it… who are you and what have you done with Ovid?

    Seriously – I am now even more shocked to see you of all people produce a God object. The way you’ve designed the class, it’s impossible to test or use any of the functionality in isolation. So I wonder why you used a class at all?

    • I wasn't too worried about producing particularly good or reusable code here, I just wanted to see what I could do with Rakudo. Oddly, I also thought that it would be a much smaller bit of code. Your turn to write hangman ... :)