Skip to content

Instantly share code, notes, and snippets.

Avatar

Brock Wilcox awwaiid

View GitHub Profile
View quick.p6
module Test::QuickCheck {
multi gen(Int) { 1000000.rand.Int }
our sub verify-one( &f, &predicate ) {
my @params = &f.signature.params.map: -> $p {
# say "Param: {$p.gist}";
gen($p.type)
};
View killme.pl6
# signal(SIGINT).tap: {
# note "Took { now - INIT now } seconds. $*THREAD";
# }
my $interrupt = signal(SIGINT);
$interrupt.tap: -> $v {
note "[got interrupt $v]";
}
View catch-control.p6
sub catch-control {
CONTROL {
die "Caught a CONTROL ({.gist})";
}
die "forced exception";
}
for 1 {
catch-control;
View catch-control.p6
sub no-catch-control {
die "no-catch-control exception";
}
sub catch-control {
CONTROL {
say "CONTROL: {$_.gist}";
die "control exception";
}
View catch-control.p6
sub no-catch-control {
die "no-catch-control exception";
}
sub catch-control {
CONTROL {
say "CONTROL: {$_.gist}";
die "control exception";
}
View example.txt
> 5+5
10
> next
CONTROL: Died with CX::Next
EXCEPTION: control exception
in sub eval at simple-repl.p6 line 8
in block <unit> at simple-repl.p6 line 34
> last
View strangeloop.md

Strange Loop talk proposal -- due 2016-05-09 http://thestrangeloop.com/cfp.html

Title: Rakudo/Perl6, The Polyglot Language

Abstract (max 1500 chars)

Taking multi-paradigm to a new level, Perl 6 goes far beyond its Perl 5 roots, adopting concepts from many languages. From Haskell/Elixir style typed multi-dispatch to Ruby style objects-all-the-way-down, you can pick a model that best fits your problem domain. Add to this some very practical innovations, such as a grammar engine and native stream/promise async/concurrency, and you have both a useful tool and an interesting experimentation platform. The production-ready Rakudo implementation of Perl 6 targets both its own MoarVM and the JVM, and a JS target is in progress!

View strangeloop.txt
Strange Loop talk proposal -- due 2016-05-09
http://thestrangeloop.com/cfp.html
Title: Rakudo/Perl6, The Polyglot Langauge
Abstract (max 1500 chars)
========
Taking multi-paradigm to a new level, Perl 6 goes far beyond it's Perl 5 roots, adopting concepts from many languages. From Haskell/Elixir style typed multi-dispatch to Ruby style objects-all-the-way-down, you can pick a model that best fits your problem domain. Add to this some very practical innovations, such as a grammar engine and native stream/promise async/concurrency, and you have both a useful tool and an interesting experimention platform. The production-ready Rakudo implementation of Perl 6 targets both it's own MoarVM and the JVM, and a JS target is in progress!
View conversion-fancy.p6
say "hello";
subset Natural of Int where * > -1;
# Using a given/when (like a case statement)
sub conv1(Natural $x) {
given $x {
when 0 { "0" }
when 1 { "1" }
when * %% 2 { conv1($x div 2) ~ "0" }
View conversion.p6
say "hello";
subset NWZ of Int where * > -1;
proto conversion(NWZ $x, $s = ""){*}
multi conversion(0, $s = "0") {
$s
}
multi conversion($x where * %% 2, $s) {
conversion($x div 2, "0" ~ $s)
}
multi conversion($x, $s) {