Created
March 24, 2015 12:05
-
-
Save MattOates/95470a79ea98f4e77357 to your computer and use it in GitHub Desktop.
Mising bits from P5 necessary for a port of the six-frame-translation perl6-bench benchmark
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 { | |
my ($callback, @sets) = @_; | |
my @cross_product = []; | |
foreach my $set (reverse @sets) { | |
my @set = @$set; | |
@cross_product = map { | |
my $item = $_; | |
map { | |
my @other_set_values = @$_; | |
[ $item, @other_set_values ] | |
} @cross_product | |
} @set; | |
} | |
@cross_product = map &$callback(@$_), @cross_product; | |
return @cross_product; | |
} | |
my @codons = X( sub {join '', @_}, ['T','C','A','G'] x 3 ); | |
my @aminos = qw(F F L L S S S S | |
Y Y * * C C * W | |
L L L L P P P P | |
H H Q Q R R R R | |
I I I M T T T T | |
N N K K S S R R | |
V V V V A A A A | |
D D E E G G G G); | |
my %translation_tables = ( standard => { zip @codons, @aminos }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment