X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FAutobox%2FList.pm;h=c54b305eaef28530e32f723e1cf274192962ecc2;hb=b3cb70385763ff1067a42fa7e470177bef3485e8;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..c54b305 100644 --- a/lib/Moose/Autobox/List.pm +++ b/lib/Moose/Autobox/List.pm @@ -1,11 +1,112 @@ package Moose::Autobox::List; use Moose::Role 'with', 'requires'; +use Moose::Autobox; -our $VERSION = '0.01'; +our $VERSION = '0.02'; with 'Moose::Autobox::Value'; -requires qw/length grep map join reverse sort/; +requires 'head'; +requires 'tail'; +requires 'length'; +requires 'join'; +requires 'grep'; +requires 'map'; +requires 'sort'; +requires '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 DESCRIPTION + +This is a role to describes a List interface. This is not +meant to be any specific Perl type, but instead an interface +that certain Perl types might implement. Currenly only +L implements this. + +=head1 METHODS + +=over 4 + +=item B + +=item B + +=back + +=over 4 + +=item B + +=back + +=head1 REQUIRED METHODS + +=over 4 + +=item B + +=item B + +=item B + +=item B + +=item B + +=item B + +=item B + +=item B + +=back + +=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-2007 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