X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FAutobox%2FList.pm;h=2c45a4ff49767f5c8a98022e20a6b83d00efa7b0;hb=31d40d7362f4154746428525561af751208b0805;hp=e7fac250d66a8ac120ff601c900ca8b113935214;hpb=e6bb88b0e1fff9794352dde571e623ae0f4e3a95;p=gitmo%2FMoose-Autobox.git diff --git a/lib/Moose/Autobox/List.pm b/lib/Moose/Autobox/List.pm index e7fac25..2c45a4f 100644 --- a/lib/Moose/Autobox/List.pm +++ b/lib/Moose/Autobox/List.pm @@ -1,11 +1,76 @@ package Moose::Autobox::List; use Moose::Role 'with', 'requires'; +use autobox; our $VERSION = '0.01'; with 'Moose::Autobox::Value'; -requires qw/length grep map join reverse sort/; +requires qw/ + head + tail + length + join + grep + map + sort + reverse +/; -1; \ No newline at end of file +sub reduce { + my ($array, $func) = @_; + my $a = $array->values; + my $acc = $a->head; + $a->tail->map(sub { $acc = $func->($acc, $_) }); + return $acc; +} + +sub zip { + my ($array, $other) = @_; + ($array->length < $other->length + ? $other + : $array) + ->keys + ->map(sub { + [ $array->at($_), $other->at($_) ] + }); +} + +1; + +__END__ + +=pod + +=head1 NAME + +Moose::Autobox::List - the List role + +=head1 SYNOPOSIS + + use Moose::Autobox; + use autobox; + +=head1 DESCRIPTION + +=head1 BUGS + +All complex software has bugs lurking in it, and this module is no +exception. If you find a bug please either email me, or add the bug +to cpan-RT. + +=head1 AUTHOR + +Stevan Little Estevan@iinteractive.comE + +=head1 COPYRIGHT AND LICENSE + +Copyright 2006 by Infinity Interactive, Inc. + +L + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut \ No newline at end of file