exercism-perl5

Repository for my Perl 5 Exercism exercises
git clone git://git.samirparikh.com/exercism-perl5
Log | Files | Refs | README

commit 8363fc8b036459685e84dbb45159327dd5f7aee2
parent a75730c8e44e52d2df37de85115a28d58e613bd2
Author: Samir Parikh <noreply@samirparikh.com>
Date:   Fri, 28 Jan 2022 16:02:22 +0000

get all tests to pass

Diffstat:
Mstrain/Strain.pm | 12++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/strain/Strain.pm b/strain/Strain.pm @@ -6,12 +6,20 @@ our @EXPORT_OK = qw<keep discard>; sub keep { my ( $input, $function ) = @_; - return undef; + my @keep; + foreach ( @{ $input } ) { + push @keep => $_ if $function->($_); + } + return \@keep; } sub discard { my ( $input, $function ) = @_; - return undef; + my @discard; + foreach ( @{ $input } ) { + push @discard => $_ unless $function->($_); + } + return \@discard; } 1;