Commit | Line | Data |
e6bb88b0 |
1 | |
2 | package Moose::Autobox::List; |
3 | use Moose::Role 'with', 'requires'; |
6cf5bcf2 |
4 | use autobox; |
e6bb88b0 |
5 | |
6 | our $VERSION = '0.01'; |
7 | |
31d40d73 |
8 | with 'Moose::Autobox::Value'; |
e6bb88b0 |
9 | |
5dc78481 |
10 | requires qw/ |
31d40d73 |
11 | head |
6cf5bcf2 |
12 | tail |
5dc78481 |
13 | length |
14 | join |
31d40d73 |
15 | grep |
16 | map |
17 | sort |
5dc78481 |
18 | reverse |
5dc78481 |
19 | /; |
20 | |
6cf5bcf2 |
21 | sub reduce { |
22 | my ($array, $func) = @_; |
23 | my $a = $array->values; |
24 | my $acc = $a->head; |
25 | $a->tail->map(sub { $acc = $func->($acc, $_) }); |
26 | return $acc; |
27 | } |
28 | |
29 | sub zip { |
30 | my ($array, $other) = @_; |
31 | ($array->length < $other->length |
32 | ? $other |
33 | : $array) |
34 | ->keys |
35 | ->map(sub { |
31d40d73 |
36 | [ $array->at($_), $other->at($_) ] |
6cf5bcf2 |
37 | }); |
38 | } |
e6bb88b0 |
39 | |
31d40d73 |
40 | 1; |
41 | |
42 | __END__ |
43 | |
44 | =pod |
45 | |
46 | =head1 NAME |
47 | |
48 | Moose::Autobox::List - the List role |
49 | |
50 | =head1 SYNOPOSIS |
51 | |
52 | use Moose::Autobox; |
53 | use autobox; |
54 | |
55 | =head1 DESCRIPTION |
56 | |
57 | =head1 BUGS |
58 | |
59 | All complex software has bugs lurking in it, and this module is no |
60 | exception. If you find a bug please either email me, or add the bug |
61 | to cpan-RT. |
62 | |
63 | =head1 AUTHOR |
64 | |
65 | Stevan Little E<lt>stevan@iinteractive.comE<gt> |
66 | |
67 | =head1 COPYRIGHT AND LICENSE |
68 | |
69 | Copyright 2006 by Infinity Interactive, Inc. |
70 | |
71 | L<http://www.iinteractive.com> |
72 | |
73 | This library is free software; you can redistribute it and/or modify |
74 | it under the same terms as Perl itself. |
75 | |
76 | =cut |