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
use QAST:from<NQP>; | |
sub BioInfo::seq(Str $sequence) is export { | |
use BioInfo::Parser::FASTA::Grammar; | |
use BioInfo::Parser::FASTA::Actions; | |
BioInfo::Parser::FASTA::Grammar.parse($sequence, actions => BioInfo::Parser::FASTA::Actions).ast; | |
} | |
sub EXPORT(|) { | |
role BioInfo::Grammar { |
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
use strict; | |
use feature 'say'; | |
use Data::Dumper; | |
use List::MoreUtils 'zip'; | |
#Implement something similar to the Perl6 X meta operator | |
#probably not the best implementation in the world | |
sub X { |
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 %words; | |
given slurp("part-of-speech.txt") { | |
my int $pos = 0; | |
my int $chars = $_.chars; | |
while $pos < $chars { | |
my int $tab = $_.index("\t", $pos); | |
my int $nl = $_.index("\n", $tab); | |
%words{$_.substr($pos, $tab - $pos)} = | |
$_.substr($tab + 1, $nl - $tab - 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
# https://raw.githubusercontent.com/kevina/wordlist/master/pos/part-of-speech.txt | |
my $input = slurp('part-of-speech.txt'); | |
my %words; | |
sub bench($name, &code) { | |
%words = (); | |
my $start = now; | |
code; | |
my $end = now; |
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 perl6 | |
use v6; | |
use Stats; | |
#Tim's original times: | |
#primes-inline-loop(1000) ran in 2.425 seconds (σ = 0.213 seconds). | |
#primes-inline-loop-upto-sqrt(1000) ran in 2.311 seconds (σ = 0.131 seconds). | |
#primes-inline-loop-upto-int-sqrt(1000) ran in 2.274 seconds (σ = 0.161). | |
sub bench($name, &code) { |
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 perl6 | |
use v6; | |
#Handle terminal colour output by installing a module | |
#panda install Term::ANSIColor | |
use Term::ANSIColor; | |
grammar HQ9Plus::Grammar { | |
#A valid REPL line is just a sequence of commands and nothing else including white space | |
token TOP { |
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 perl | |
#Write sane perl | |
use strict; | |
use warnings; | |
use feature 'say'; | |
#Use some modules which are sufficiently round wheels | |
use Text::CSV; | |
use Getopt::Long; |
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 perl6 | |
use v6; | |
use Stats; | |
sub bench($name, &code) { | |
my ($start,$end); | |
my $max = 1000; | |
my @times; |
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 perl6 | |
for 'data.tsv'.IO.lines {} |
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 perl6 | |
use v6; | |
use Stats; | |
sub bench(Str $name, Int $upto, &code) { | |
my ($start,$end); | |
my @times; | |
for 1..20 { |