Mercurial > rlmcintyre
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:0d795f02a8bb |
---|---|
1 sub filter | |
2 { | |
3 | |
4 $ref = shift; | |
5 @list = @_; | |
6 my @ret = (); | |
7 | |
8 for $element(@list) | |
9 { | |
10 if ($ref->($element)) | |
11 { | |
12 push @ret, $element; | |
13 } | |
14 } | |
15 | |
16 return @ret | |
17 | |
18 } | |
19 | |
20 | |
21 | |
22 | |
23 @test = (1,2,3,4,5,6); | |
24 | |
25 sub even | |
26 { | |
27 return ($_[0]%2 == 0); | |
28 } | |
29 | |
30 @rr = &filter(\&even, @test); | |
31 | |
32 print "@rr"; |