Mercurial > boosterpack
view filter.pl @ 10:3b52ac950753 boosterpack tip
going to try to fix this thing
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 27 Sep 2010 17:24:06 -0400 |
parents | 8c6d2ce90677 |
children |
line wrap: on
line source
1 #!/usr/bin/perl3 sub filter4 {6 $ref = shift;7 @list = @_;8 my @ret = ();10 for $element(@list)11 {12 if ($ref->($element))13 {14 push @ret, $element;15 }16 }18 return @ret20 }25 @test = (1,2,3,4,5,6);27 sub even28 {29 return ($_[0]%2 == 0);30 }32 @rr = &filter(\&even, @test);34 print "@rr";