This file contains 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
# | |
# The Great Computer Language Shootout | |
# http://shootout.alioth.debian.org/ | |
# | |
# contributed by Christoph Bauer | |
# converted into Perl by Márton Papp | |
# | |
my num $pi = 3.141592653589793e0; | |
my num $solar_mass =(4 * $pi * $pi); |
This file contains 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 python3.2 | |
import subprocess, re | |
matchers = { | |
'../scripts/public-add': re.compile('[AM]\tpublic/[\w.]'), | |
'../scripts/public-del': re.compile('D\tpublic/[\w.]'), | |
} | |
for line in subprocess.check_output(["git", "show", "--name-status"]).decode().split('\n')[4:-1]: |
This file contains 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
perl6-m -e 'Supply.merge(Supply.interval(2).map({ "tick" }), Supply.interval(2, 1).map({ "tock" })).tap(&say); sleep 10;' | |
tick | |
tock | |
tick | |
tock | |
tick | |
tock | |
tick | |
tock | |
tick |
This file contains 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
Hey! | |
This is a poll about VMs for Perl 6. It would be awesome if you fill it, | |
just write a comment with your answers. | |
I need it because I work on a huge summary (including, among the others, statistics, tests) | |
of VMs and Perl 6 itself. | |
Thank you very much in advance! | |
sergot |
This file contains 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
my $in = "rakudo-parrot c8ec1d, rakudo-jvm c8ec1d, rakudo-moar c8ec1d"; | |
my @pieces = $in.split(", "); | |
my $common-prefix; | |
for 1..$in.chars { | |
last unless [eq] @pieces>>.substr(0,$_); | |
$common-prefix = @pieces[0].substr(0,$_); | |
} | |
@pieces = @pieces>>.substr($common-prefix.chars); | |
my $common-suffix; |
This file contains 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 agm( $a is copy, $g is copy ) { | |
($a, $g) = ($a + $g)/2, sqrt $a * $g | |
until abs($a - $g) < 0.000001; | |
return $a; | |
} | |
say agm 1, 1/sqrt 2; |
This file contains 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
my constant $WINNER_KIND_DONE = 0; | |
my constant $WINNER_KIND_MORE = 1; | |
sub WINNER(@winner_args, *@pieces, :$wild_done, :$wild_more, :$later) { | |
my Int $num_pieces = +@pieces div 3; | |
sub invoke_right(&block, $key, $value?) { | |
my @names = map *.name, &block.signature.params; | |
say @names; | |
return do if @names eqv ['$k', '$v'] || @names eqv ['$v', '$k'] { | |
&block(:k($key), :v($value)); |
This file contains 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
my int $COUNT := 1000; | |
my int $DATA_SIZE := 4; | |
my int $ID_IDLE := 0; | |
my int $ID_WORKER := 1; | |
my int $ID_HANDLER_A := 2; | |
my int $ID_HANDLER_B := 3; | |
my int $ID_DEVICE_A := 4; | |
my int $ID_DEVICE_B := 5; | |
my int $NUMBER_OF_IDS := 6; |
This file contains 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 Table { | |
token TOP { | |
<pod_block> | |
} | |
token pod_newline { | |
\h* \n | |
} | |
method insert_column_part($text, $column, @text-pieces, @columns, $columns-fixed = False) { |
This file contains 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 Foo is Array { | |
multi method postcircumfix:<[ ]>(\SELF: LoL $coords) is rw { | |
my $subcoords = $coords[1..^*].lol; | |
if +@$subcoords == 1 { | |
$subcoords = $subcoords[0].list; | |
} | |
for $coords[0].list { | |
SELF[$_][@$subcoords]; | |
} | |
} |