This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use nqp; | |
use QAST:from<NQP>; | |
sub EXPORT(|) { | |
role MOSDEF::Grammar { | |
token def { [ \'.*?\' || \".*?\" || .]*? )> <before ';'> } # ' | |
rule routine_declarator:def { <sym> <routine_def('def')> } | |
rule routine_declarator:sym<def> { <sym> <def> } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl6 | |
my \x = "mütter"; | |
my \y = "mütter"; | |
if x eq y { | |
say "same" | |
} else { | |
say "different" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#-*- encoding: utf8 -*- | |
x = "mütter"; | |
y = "mütter"; | |
if x == y: | |
print "same" | |
else: | |
print "different" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dee is Date { | |
has &!formatter = sub { "foo" }; | |
} | |
say Dee.new('2014-01-01'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub random-prime(:$digits) { | |
repeat { $_ = (10**$digits .. (10**($digits+1))).pick } until .is-prime; | |
return $_; | |
} | |
sub encrypt(:$message, :$key) { | |
return expmod($message,$key[0],$key[1]) | |
} | |
sub decrypt(:$message, :$key) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl6 | |
grammar divspl { | |
rule TOP { <x=int>..<y=int> <assignment>+ } | |
rule assignment { <word> '=' <mod=int> } | |
token word { \w+ } | |
token int { \d+ } | |
} | |
# Custom operator: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use nqp; | |
use QAST:from<NQP>; | |
# Slang to make "dog" a synonym for "do" | |
role Dogdo::Grammar { | |
token statement_prefix:sym<dog> { <sym><.kok> <blorst> } | |
} | |
role Dogdo::Actions { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use nqp; | |
use QAST:from<NQP>; | |
# Slang to make "dog" a synonym for "do" | |
role Dogdo::Grammar { | |
token statement_prefix:sym<dog> { <sym><.kok> <blorst> } | |
} | |
role Dogdo::Actions { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl6 | |
my @dates = Date.today, Date.today.succ ... ∞; | |
my %taken = | |
# first wednesday | |
plug-central => { $_.day-of-week == 3 and $_.weekday-of-month == 1 }, | |
# second tuesday | |
plug-north => { $_.day-of-week == 2 and $_.weekday-of-month == 2 }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl6 | |
# parse a little slim (<http://slim-lang.com>) | |
grammar slim { | |
rule TOP { <line>+ %% <eol>} | |
token line { <indentation> <tag> [ ' ' <text> ]? } | |
token indentation { <indent>* } | |
token indent { ' ' } | |
token tag { \w+ } |