Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created August 3, 2016 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/31bddde0a0eb4227f7b194dcfe8104ab to your computer and use it in GitHub Desktop.
Save zoffixznet/31bddde0a0eb4227f7b194dcfe8104ab to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl6
sub term:<πŸ‘Š> { 'Rock' }
sub term:<βœ‹> { 'Paper' }
sub term:<✌> { 'Scissors' }
multi infix:<✊>(βœ‹, πŸ‘Š) { True }
multi infix:<✊>(πŸ‘Š, ✌) { True }
multi infix:<✊>(✌ , βœ‹) { True }
multi infix:<✊>($ , $ ) { False }
my $p1 = (πŸ‘Š, βœ‹, ✌).roll;
say "Player 1 chooses: {$p1}";
my $p2 = (πŸ‘Š, βœ‹, ✌).roll;
say "Player 2 chooses: {$p2}";
say do {
when $p1 ✊ $p2 { "Player 1 wins!"}
when $p2 ✊ $p1 { "Player 2 wins!"}
default { "It's a tie!" }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment