X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FAutobox%2FArray.pm;h=e236fc9168d571fa0957b5af3870b4e78e28ebc6;hb=7dad276528d940b1475e55f8acfdc9414ba1f6bc;hp=97ac19a1edb65b4556f47cdf455e1183025b00e9;hpb=5272f13f684d461d95aa45de22d8776a98c03c64;p=gitmo%2FMoose-Autobox.git diff --git a/lib/Moose/Autobox/Array.pm b/lib/Moose/Autobox/Array.pm index 97ac19a..e236fc9 100644 --- a/lib/Moose/Autobox/Array.pm +++ b/lib/Moose/Autobox/Array.pm @@ -1,8 +1,9 @@ package Moose::Autobox::Array; use Moose::Role 'with'; -use autobox; +use Perl6::Junction; +use Moose::Autobox; -our $VERSION = '0.01'; +our $VERSION = '0.03'; with 'Moose::Autobox::Ref', 'Moose::Autobox::List', @@ -35,7 +36,12 @@ sub delete { sub shift { my ($array) = @_; CORE::shift @$array; -} +} + +sub slice { + my ($array, $indicies) = @_; + [ @{$array}[ @{$indicies} ] ]; +} # NOTE: # sprintf args need to be reversed, @@ -111,6 +117,28 @@ sub kv { $array->keys->map(sub { [ $_, $array->[$_] ] }); } +## Junctions + +sub all { + my ($array) = @_; + return Perl6::Junction::All->all(@$array); +} + +sub any { + my ($array) = @_; + return Perl6::Junction::Any->any(@$array); +} + +sub none { + my ($array) = @_; + return Perl6::Junction::None->none(@$array); +} + +sub one { + my ($array) = @_; + return Perl6::Junction::One->one(@$array); +} + 1; __END__ @@ -133,6 +161,8 @@ Moose::Autobox::Array - the Array role print "Squares: " . [ 1 .. 10 ]->map(sub { $_ * $_ })->join(', '); print [ 1, 'number' ]->sprintf('%d is the loneliest %s'); + + print ([ 1 .. 5 ]->any == 3) ? 'true' : 'false'; # prints 'true' =head1 DESCRIPTION @@ -154,6 +184,8 @@ This is a role to describe operations on the Array type. =item B +=item B + =back =head2 Indexed implementation @@ -196,6 +228,20 @@ This is a role to describe operations on the Array type. =back +=head2 Junctions + +=over 4 + +=item B + +=item B + +=item B + +=item B + +=back + =over 4 =item B @@ -221,4 +267,4 @@ 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 +=cut