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
# Macro definition, like, Perl 6 grammars, will use () for capturing subgroup | |
# and [] for noncapturing grouping, and <...> to generate named parsing rules | |
macro manip_select | |
{ | |
'select' ( | |
'*' | | |
[ [ <ident> '(' <ident> ')' | <ident> ] ** ',' ] | |
) 'from' <term> | |
('where' ( |
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 fn; | |
use 5.010; | |
fn foo ($f, $a; $extra) { | |
say "going to call with ($a)"; | |
$f->($a); | |
if (defined($extra)) { | |
say "got extra: $extra"; | |
} | |
say "done with call"; |
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
# Solved in 16.5s | |
use Math::Prime; | |
sub factor_one($number) { | |
my @primes := primes(); | |
for @primes ... * > sqrt $number -> $n { | |
return $n if $number %% $n; | |
} | |
} |
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
knowhow RubyClassHOW { | |
has $!parent; | |
has $!parent_set; | |
has $!name; | |
has %!methods; | |
has %!attributes; | |
has $!virtual; | |
method new(:$name, :$virtual) { | |
my $obj := pir::repr_instance_of__PP(self); |
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
grammar eria::Grammar is HLL::Grammar; | |
token TOP { | |
<statementlist> | |
} | |
rule statementlist { <affectation>+ } | |
rule affectation { |
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
0 -> 1 | |
1 -> 2 | |
2 -> 0 | |
0 -> 3 | |
3 -> 2 | |
2 -> 7 | |
7 -> 1 | |
1 -> 5 | |
5 -> 0 | |
0 -> 4 |
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
[sweeks@sweeks-laptop ~]$ perl /tmp/config.pl | |
$VAR1 = { | |
'bar' => '2', | |
'omg' => '29', | |
'lol' => '3', | |
'foo' => '1' | |
}; |
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 MooseX::Declare; | |
use feature ':5.10'; | |
class Log { | |
use Moose::Util::TypeConstraints; | |
our $foo; | |
BEGIN { | |
enum 'RGB' => qw/red green blue/; | |
$foo = "lol ohai"; | |
} | |
use Logger; |
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
package Lol; | |
use Exception::Class ( | |
'Foo', | |
); | |
sub import { | |
print "before throwing\n"; | |
throw Foo("OHAI"); | |
print "after throwing\n"; | |
} |
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
[sweeks@sweeks-laptop ~]$ exec 3>/tmp/lolcats | |
[sweeks@sweeks-laptop ~]$ exec 4>/tmp/walrus | |
[sweeks@sweeks-laptop ~]$ ls -l /proc/self/fd/{3,4} | |
l-wx------. 1 sweeks sweeks 64 Dec 7 16:51 /proc/self/fd/3 -> /tmp/lolcats | |
l-wx------. 1 sweeks sweeks 64 Dec 7 16:51 /proc/self/fd/4 -> /tmp/walrus | |
[sweeks@sweeks-laptop ~]$ exec 4>&3 | |
[sweeks@sweeks-laptop ~]$ ls -l /proc/self/fd/{3,4} | |
l-wx------. 1 sweeks sweeks 64 Dec 7 16:51 /proc/self/fd/3 -> /tmp/lolcats | |
l-wx------. 1 sweeks sweeks 64 Dec 7 16:51 /proc/self/fd/4 -> /tmp/lolcats |