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 | |
use Modern::Perl; | |
sub is_prime { | |
my $n = shift; | |
$n <= 1 and return; | |
my $i = 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
primes :: [Integer] | |
primes = 2 : filter isPrime [3, 5 ..] | |
where | |
-- only check divisibility of the numbers less than the square root of n | |
isPrime n = all (not . divides n) $ takeWhile (\p -> p*p <= n) primes | |
divides n p = n `mod` p == 0 | |
result = sum $ takeWhile (< 2000000) primes | |
main = do putStrLn( show result ) |
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 | |
use Modern::Perl; | |
use Sub::Call::Recur; | |
use Sub::Call::Tail; | |
use Benchmark 'cmpthese'; | |
no warnings 'recursion'; | |
sub fact_recur { | |
my ($n, $accum) = @_; |
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
coerce BioSimpleAlign, | |
from BioSeqIO, via { _seq_to_aln( _seqI_to_seq($_) ) }, | |
from BioSeq, via { _seq_to_aln($_) }, | |
from BioAlignIO, via { $_->next_aln }, | |
from ProfileFile, via { _filename_to_aln($_) }; |
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
brunov@dora:~$ re.pl | |
$_ my $thing = Foo->new; | |
$Foo1 = Foo=HASH(0xa77cb98) | |
$_ my $other = Bar->new; | |
$Bar1 = Bar=HASH(0xabc4eb8) |
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
# in ~/.repl/repl.rc: | |
use Class::Autouse qw(:superloader); |
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 Class::Autouse qw(:superloader); | |
my $thing = Dep::2->new; |
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 @deps; push "Dep::$_" for (1..10); | |
use Class::Autouse @deps; | |
my $thing = Dep::2->new; |
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 Dep::1; | |
use Dep::2; | |
... | |
use Dep::10; | |
my $thing = Dep::2->new; |
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/perl | |
use Modern::Perl; | |
use POE qw(Component::DirWatch::Object::NewFile); | |
use Bio::SeqIO; | |
use Bio::Seq; | |
use File::Temp; | |
use File::Copy qw(move); | |
use Gtk2::Notify -init, "Translator"; | |
my $watcher = POE::Component::DirWatch::Object::NewFile->new( |