annotate BoosterPack/.svn/text-base/filter.pl.svn-base @ 0:0d795f02a8bb tip

initial committ. what was I thinking?
author Robert McIntyre <rlm@mit.edu>
date Mon, 27 Sep 2010 16:57:26 -0400
parents
children
rev   line source
rlm@0 1 sub filter
rlm@0 2 {
rlm@0 3
rlm@0 4 $ref = shift;
rlm@0 5 @list = @_;
rlm@0 6 my @ret = ();
rlm@0 7
rlm@0 8 for $element(@list)
rlm@0 9 {
rlm@0 10 if ($ref->($element))
rlm@0 11 {
rlm@0 12 push @ret, $element;
rlm@0 13 }
rlm@0 14 }
rlm@0 15
rlm@0 16 return @ret
rlm@0 17
rlm@0 18 }
rlm@0 19
rlm@0 20
rlm@0 21
rlm@0 22
rlm@0 23 @test = (1,2,3,4,5,6);
rlm@0 24
rlm@0 25 sub even
rlm@0 26 {
rlm@0 27 return ($_[0]%2 == 0);
rlm@0 28 }
rlm@0 29
rlm@0 30 @rr = &filter(\&even, @test);
rlm@0 31
rlm@0 32 print "@rr";