line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Moose::Autobox::List; |
2
|
|
|
|
|
|
|
# ABSTRACT: the List role |
3
|
14
|
|
|
14
|
|
6190
|
use Moose::Role 'with', 'requires'; |
|
14
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
91
|
|
4
|
14
|
|
|
14
|
|
43082
|
use Moose::Autobox; |
|
14
|
|
|
|
|
30
|
|
|
14
|
|
|
|
|
101
|
|
5
|
14
|
|
|
14
|
|
6162
|
use namespace::autoclean; |
|
14
|
|
|
|
|
24
|
|
|
14
|
|
|
|
|
94
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.16'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with 'Moose::Autobox::Value'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
requires 'head'; |
12
|
|
|
|
|
|
|
requires 'tail'; |
13
|
|
|
|
|
|
|
requires 'length'; |
14
|
|
|
|
|
|
|
requires 'join'; |
15
|
|
|
|
|
|
|
requires 'grep'; |
16
|
|
|
|
|
|
|
requires 'map'; |
17
|
|
|
|
|
|
|
requires 'sort'; |
18
|
|
|
|
|
|
|
requires 'reverse'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub reduce { |
21
|
1
|
|
|
1
|
1
|
2
|
my ($array, $func) = @_; |
22
|
1
|
|
|
|
|
4
|
my $a = $array->values; |
23
|
1
|
|
|
|
|
8
|
my $acc = $a->head; |
24
|
1
|
|
|
4
|
|
5
|
$a->tail->map(sub { $acc = $func->($acc, $_) }); |
|
4
|
|
|
|
|
5
|
|
25
|
1
|
|
|
|
|
7
|
return $acc; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub zip { |
29
|
3
|
|
|
3
|
1
|
9
|
my ($array, $other) = @_; |
30
|
|
|
|
|
|
|
($array->length < $other->length |
31
|
|
|
|
|
|
|
? $other |
32
|
|
|
|
|
|
|
: $array) |
33
|
|
|
|
|
|
|
->keys |
34
|
|
|
|
|
|
|
->map(sub { |
35
|
16
|
|
|
16
|
|
29
|
[ $array->at($_), $other->at($_) ] |
36
|
3
|
100
|
|
|
|
13
|
}); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=pod |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=encoding UTF-8 |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 NAME |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Moose::Autobox::List - the List role |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 VERSION |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
version 0.16 |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 DESCRIPTION |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This is a role to describes a List interface. This is not |
58
|
|
|
|
|
|
|
meant to be any specific Perl type, but instead an interface |
59
|
|
|
|
|
|
|
that certain Perl types might implement. Currently only |
60
|
|
|
|
|
|
|
L<Moose::Autobox::Array> implements this. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 METHODS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=over 4 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item C<reduce> |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item C<zip> |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=back |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=over 4 |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item C<meta> |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=back |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 REQUIRED METHODS |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=over 4 |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item C<head> |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item C<tail> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item C<join> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item C<length> |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item C<map> |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item C<grep> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item C<reverse> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item C<sort> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=back |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 SUPPORT |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Moose-Autobox> |
103
|
|
|
|
|
|
|
(or L<bug-Moose-Autobox@rt.cpan.org|mailto:bug-Moose-Autobox@rt.cpan.org>). |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
There is also a mailing list available for users of this distribution, at |
106
|
|
|
|
|
|
|
L<http://lists.perl.org/list/moose.html>. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
There is also an irc channel available for users of this distribution, at |
109
|
|
|
|
|
|
|
L<C<#moose> on C<irc.perl.org>|irc://irc.perl.org/#moose>. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 AUTHOR |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Stevan Little <stevan.little@iinteractive.com> |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This software is copyright (c) 2006 by Infinity Interactive, Inc. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
120
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |