diff --git a/lib/Sidef/Types/Array/Array.pm b/lib/Sidef/Types/Array/Array.pm index b45aa118c..b72c2add6 100644 --- a/lib/Sidef/Types/Array/Array.pm +++ b/lib/Sidef/Types/Array/Array.pm @@ -2250,6 +2250,8 @@ package Sidef::Types::Array::Array { bless \@acc, ref($self); } + *acc_by = \&accumulate_by; + sub accumulate { my ($self, $block) = @_; @@ -2272,6 +2274,28 @@ package Sidef::Types::Array::Array { bless \@acc, ref($self); } + *acc = \&accumulate; + + sub differences { + my ($self, $n) = @_; + + if (defined($n)) { + $n = CORE::int($n); + } + else { + $n = 1; + } + + foreach my $i (1 .. $n) { + $self = $self->map_cons(2, Sidef::Types::Block::Block->new(code => sub { $_[1]->sub($_[0]) })); + } + + $self; + } + + *diffs = \&differences; + *nth_differences = \&differences; + sub reduce { my ($self, $obj, $initial) = @_; diff --git a/lib/Sidef/Types/Array/Array.pod b/lib/Sidef/Types/Array/Array.pod index d0d2c9368..f06ce086c 100644 --- a/lib/Sidef/Types/Array/Array.pod +++ b/lib/Sidef/Types/Array/Array.pod @@ -260,20 +260,24 @@ Aliases: I =cut -=head2 accumulate +=head2 acc -Array.accumulate() -> I +Array.acc() -> I Return the +Aliases: I + =cut -=head2 accumulate_by +=head2 acc_by -Array.accumulate_by() -> I +Array.acc_by() -> I Return the +Aliases: I + =cut =head2 all @@ -670,6 +674,16 @@ Return the =cut +=head2 diffs + +Array.diffs() -> I + +Return the + +Aliases: I, I + +=cut + =head2 dig Array.dig() -> I