aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-186/kueppo-wesley/Perl/ch-1.pl22
1 files changed, 22 insertions, 0 deletions
diff --git a/challenge-186/kueppo-wesley/Perl/ch-1.pl b/challenge-186/kueppo-wesley/Perl/ch-1.pl
new file mode 100644
index 0000000000..eb0e63f1ec
--- /dev/null
+++ b/challenge-186/kueppo-wesley/Perl/ch-1.pl
@@ -0,0 +1,22 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+sub zip {
+ my ( $a, $b ) = @_;
+
+ # Boils down to iterating over elements
+ return map { $a->[ $_ ], $b->[ $_ ] } 0 .. ( @$a > @$b ? $#$b : $#$a );
+}
+
+my @a = qw/1 2 3/;
+my @b = qw/a b c/;
+
+# Testing..
+is_deeply [ zip( \@a, \@b ) ], [ qw/1 a 2 b 3 c/ ], "Zipped?";
+is_deeply [ zip( \@b, \@a ) ], [ qw/a 1 b 2 c 3/ ], "Zipped?";
+
+done_testing( 2 );