line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PartialApplication; |
2
|
2
|
|
|
2
|
|
85501
|
use 5.008001; |
|
2
|
|
|
|
|
18
|
|
3
|
2
|
|
|
2
|
|
29
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
45
|
|
4
|
2
|
|
|
2
|
|
17
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
80
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.02"; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
12
|
use Exporter 'import'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
89
|
|
9
|
2
|
|
|
2
|
|
27
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
724
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw( partiallyApply partiallyApplyRight partiallyApplyN ); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub partiallyApply { |
14
|
4
|
|
|
4
|
1
|
3198
|
my ( $sub, @params ) = @_; |
15
|
|
|
|
|
|
|
|
16
|
4
|
100
|
|
|
|
42
|
croak "first parameter needs to be a function ref" unless ref $sub eq "CODE"; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
return sub { |
19
|
4
|
|
|
4
|
|
10663
|
$sub->( @params, @_ ); |
20
|
2
|
|
|
|
|
16
|
}; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub partiallyApplyRight { |
24
|
3
|
|
|
3
|
1
|
2852
|
my ( $sub, @params ) = @_; |
25
|
|
|
|
|
|
|
|
26
|
3
|
100
|
|
|
|
27
|
croak "first parameter needs to be a function ref" unless ref $sub eq "CODE"; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
return sub { |
29
|
2
|
|
|
2
|
|
1326
|
$sub->( @_, @params ); |
30
|
1
|
|
|
|
|
7
|
}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub partiallyApplyN { |
34
|
4
|
|
|
4
|
1
|
4067
|
my ( $sub, $bitmap, @partialParams ) = @_; |
35
|
|
|
|
|
|
|
|
36
|
4
|
100
|
|
|
|
33
|
croak "first parameter needs to be a function ref" unless ref $sub eq "CODE"; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
return sub { |
39
|
4
|
|
|
4
|
|
2679
|
my ( @callParams ) = @_; |
40
|
|
|
|
|
|
|
|
41
|
4
|
|
|
|
|
10
|
my @partial = @partialParams; |
42
|
|
|
|
|
|
|
|
43
|
4
|
100
|
|
|
|
8
|
my @params = map { $_ ? shift @partial : shift @callParams } @{ $bitmap }; |
|
18
|
|
|
|
|
39
|
|
|
4
|
|
|
|
|
9
|
|
44
|
|
|
|
|
|
|
|
45
|
4
|
|
|
|
|
13
|
$sub->( @params, @partial, @callParams ); |
46
|
|
|
|
|
|
|
} |
47
|
2
|
|
|
|
|
17
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
__END__ |