Skip to content

Commit

Permalink
- Added the Array .binsplit {|a,b| ... } method.
Browse files Browse the repository at this point in the history
Applies the binary splitting algorithm to a the self-array, returning the result computed with the given block of code.

Example:

	say [1,2,3,4,5].binsplit {|a,b| a*b }	#=> 120
  • Loading branch information
trizen committed Mar 20, 2022
1 parent 609d4b8 commit 146052b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/Sidef/Types/Array/Array.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2343,6 +2343,11 @@ package Sidef::Types::Array::Array {
$poly;
}

sub binsplit {
my ($self, $block) = @_;
Sidef::Math::Math->binsplit($block, @$self);
}

sub reduce {
my ($self, $obj, $initial) = @_;

Expand Down Expand Up @@ -3390,7 +3395,7 @@ package Sidef::Types::Array::Array {
push @result, bless [@_]; # don't bless \@_
},
map { [@$_] } @$self
);
);

return bless \@result;
}
Expand Down
8 changes: 8 additions & 0 deletions lib/Sidef/Types/Array/Array.pod
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,14 @@ Returns the

=cut

=head2 binsplit

Array.binsplit()

Returns the

=cut

=head2 bsearch

Array.bsearch()
Expand Down

0 comments on commit 146052b

Please sign in to comment.