Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / Moose / Autobox / List.pm
CommitLineData
3fea05b9 1
2package Moose::Autobox::List;
3use Moose::Role 'with', 'requires';
4use Moose::Autobox;
5
6our $VERSION = '0.10';
7
8with 'Moose::Autobox::Value';
9
10requires 'head';
11requires 'tail';
12requires 'length';
13requires 'join';
14requires 'grep';
15requires 'map';
16requires 'sort';
17requires 'reverse';
18
19sub reduce {
20 my ($array, $func) = @_;
21 my $a = $array->values;
22 my $acc = $a->head;
23 $a->tail->map(sub { $acc = $func->($acc, $_) });
24 return $acc;
25}
26
27sub zip {
28 my ($array, $other) = @_;
29 ($array->length < $other->length
30 ? $other
31 : $array)
32 ->keys
33 ->map(sub {
34 [ $array->at($_), $other->at($_) ]
35 });
36}
37
381;
39
40__END__
41
42=pod
43
44=head1 NAME
45
46Moose::Autobox::List - the List role
47
48=head1 DESCRIPTION
49
50This is a role to describes a List interface. This is not
51meant to be any specific Perl type, but instead an interface
52that certain Perl types might implement. Currenly only
53L<Moose::Autobox::Array> implements this.
54
55=head1 METHODS
56
57=over 4
58
59=item B<reduce>
60
61=item B<zip>
62
63=back
64
65=over 4
66
67=item B<meta>
68
69=back
70
71=head1 REQUIRED METHODS
72
73=over 4
74
75=item B<head>
76
77=item B<tail>
78
79=item B<join>
80
81=item B<length>
82
83=item B<map>
84
85=item B<grep>
86
87=item B<reverse>
88
89=item B<sort>
90
91=back
92
93=head1 BUGS
94
95All complex software has bugs lurking in it, and this module is no
96exception. If you find a bug please either email me, or add the bug
97to cpan-RT.
98
99=head1 AUTHOR
100
101Stevan Little E<lt>stevan@iinteractive.comE<gt>
102
103=head1 COPYRIGHT AND LICENSE
104
105Copyright 2006-2008 by Infinity Interactive, Inc.
106
107L<http://www.iinteractive.com>
108
109This library is free software; you can redistribute it and/or modify
110it under the same terms as Perl itself.
111
112=cut