diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2020-05-09 03:26:41 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2020-05-09 03:26:41 +0100 |
| commit | a2292a9824c3545abc160c1b909dec60102fb251 (patch) | |
| tree | 2bd982bbb88a99a38554e404aaa69e4769f4f917 /challenge-059/mohammad-anwar/perl/ch-1a.pl | |
| parent | 42497f56acb5263f25c9baf5d3e521242333d6e7 (diff) | |
| download | perlweeklychallenge-club-a2292a9824c3545abc160c1b909dec60102fb251.tar.gz perlweeklychallenge-club-a2292a9824c3545abc160c1b909dec60102fb251.tar.bz2 perlweeklychallenge-club-a2292a9824c3545abc160c1b909dec60102fb251.zip | |
- Added Perl and Raku solutions to Linked List task.
Diffstat (limited to 'challenge-059/mohammad-anwar/perl/ch-1a.pl')
| -rw-r--r-- | challenge-059/mohammad-anwar/perl/ch-1a.pl | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/challenge-059/mohammad-anwar/perl/ch-1a.pl b/challenge-059/mohammad-anwar/perl/ch-1a.pl new file mode 100644 index 0000000000..7be98d1233 --- /dev/null +++ b/challenge-059/mohammad-anwar/perl/ch-1a.pl @@ -0,0 +1,25 @@ +#!/usr/bin/perl + +use Test::More; +use Test::Deep; + +is_deeply( split_list([ 1, 4, 3, 2, 5, 2 ], 3), [ 1, 2, 2, 4, 3, 5 ]); + +done_testing; + +sub split_list { + my ($L, $K) = @_; + + my $before = []; + my $after = []; + foreach my $i (@$L) { + if ($i < $K) { + push @$before, $i; + } + else { + push @$after, $i; + } + } + + return [ @$before, @$after ]; +} |
