| blib/lib/Function/Composition.pm | |||
|---|---|---|---|
| Criterion | Covered | Total | % |
| statement | 15 | 15 | 100.0 |
| branch | n/a | ||
| condition | n/a | ||
| subroutine | 5 | 5 | 100.0 |
| pod | 0 | 1 | 0.0 |
| total | 20 | 21 | 95.2 |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | package Function::Composition; | ||||||
| 2 | 2 | 2 | 881 | use strict; | |||
| 2 | 4 | ||||||
| 2 | 78 | ||||||
| 3 | 2 | 2 | 11 | use warnings; | |||
| 2 | 4 | ||||||
| 2 | 98 | ||||||
| 4 | our $VERSION = '0.0.2'; | ||||||
| 5 | |||||||
| 6 | 2 | 2 | 2206 | use parent qw(Exporter); | |||
| 2 | 1124 | ||||||
| 2 | 12 | ||||||
| 7 | our @EXPORT_OK = qw(compose); | ||||||
| 8 | |||||||
| 9 | sub compose { | ||||||
| 10 | 1 | 1 | 0 | 131 | my @functions = reverse @_; | ||
| 11 | return sub { | ||||||
| 12 | 1 | 1 | 10 | my @res = @_; | |||
| 13 | 1 | 3 | for my $f (@functions) { | ||||
| 14 | 2 | 84 | @res = $f->(@res); | ||||
| 15 | } | ||||||
| 16 | 1 | 82 | @res; | ||||
| 17 | } | ||||||
| 18 | 1 | 15 | } | ||||
| 19 | |||||||
| 20 | 1; | ||||||
| 21 | __END__ |