Hydrogen::Topic::ArrayRef - functions from Hydrogen::ArrayRef applied to $_
$_
This documentation is for Hydrogen::Topic::ArrayRef 0.016, which is based on Sub::HandlesVia::HandlerLibrary::Array 0.037.
Each function implicitly operates on $_, expecting it to be a reference to an array.
accessor( $index, $value? )
Operates on $_, which must be a reference to an array.
Arguments: Int, Optional[Any].
Acts like get if given one argument, or set if given two arguments.
get
set
all()
All elements in the array, in list context.
all_true( $coderef )
Arguments: CodeRef.
Like List::Util::all().
List::Util::all()
any( $coderef )
Like List::Util::any().
List::Util::any()
apply( $coderef )
Executes the coderef (which should modify $_) against each element of the array; returns the resulting array in list context.
clear()
Empties the array.
count()
The number of elements in the referenced array.
delete( $index )
Arguments: Int.
Removes the indexed element from the array and returns it. Elements after it will be "moved up".
elements()
All elements in the array, in list context. (Essentially the same as all.)
all
first( $coderef )
Like List::Util::first().
List::Util::first()
first_index( $coderef )
Like List::MoreUtils::first_index().
List::MoreUtils::first_index()
flatten()
flatten_deep( $depth? )
Arguments: Optional[Int].
Flattens the arrayref into a list, including any nested arrayrefs. (Has the potential to loop infinitely.)
for_each( $coderef )
Function which executes the coderef on each element of the array. The coderef will be passed two values: the element and its index.
for_each_pair( $coderef )
Function which executes the coderef on each pair of elements in the array. The coderef will be passed the two elements.
get( $index )
Returns a single element from the array by index.
grep( $coderef )
Like grep from perlfunc.
grep
head( $count )
Returns the first $count elements of the array in list context.
$count
insert( $index, $value )
Arguments: Int, Any.
Inserts a value into the array with the given index. Elements after it will be "moved down".
is_empty()
Boolean indicating if the referenced array is empty.
join( $with? )
Arguments: Optional[Str].
Returns a string joining all the elements in the array; if $with is omitted, defaults to a comma.
$with
map( $coderef )
Like map from perlfunc.
map
max()
Like List::Util::max().
List::Util::max()
maxstr()
Like List::Util::maxstr().
List::Util::maxstr()
min()
Like List::Util::min().
List::Util::min()
minstr()
Like List::Util::minstr().
List::Util::minstr()
natatime( $n, $callback? )
Arguments: Int, Optional[CodeRef].
Given just a number, returns an iterator which reads that many elements from the array at a time. If also given a callback, calls the callback repeatedly with those values.
not_all_true( $coderef )
Like List::Util::notall().
List::Util::notall()
pairfirst( $coderef )
Like List::Util::pairfirst().
List::Util::pairfirst()
pairgrep( $coderef )
Like List::Util::pairgrep().
List::Util::pairgrep()
pairkeys()
Like List::Util::pairkeys().
List::Util::pairkeys()
pairmap( $coderef )
Like List::Util::pairmap().
List::Util::pairmap()
pairs()
Like List::Util::pairs().
List::Util::pairs()
pairvalues()
Like List::Util::pairvalues().
List::Util::pairvalues()
pick_random( $count )
If no $count is given, returns one element of the array at random. If $count is given, creates a new array with that many random elements from the original array (or fewer if the original array is not long enough) and returns that as an arrayref or list depending on context
pop()
Removes the last element from the array and returns it.
print( $fh?, $with? )
Arguments: Optional[FileHandle], Optional[Str].
Prints a string joining all the elements in the array; if $fh is omitted, defaults to STDOUT; if $with is omitted, defaults to a comma.
$fh
product()
Like List::Util::product().
List::Util::product()
push( @values )
Adds elements to the end of the array.
reduce( $coderef )
Like List::Util::reduce().
List::Util::reduce()
reductions( $coderef )
Like List::Util::reductions().
List::Util::reductions()
reset()
Resets the original value to its default value, or an empty arrayref if it has no default.
reverse()
Returns the reversed array in list context.
sample( $count )
Like List::Util::sample().
List::Util::sample()
set( $index, $value )
Sets the element with the given index to the supplied value.
shallow_clone()
Creates a new arrayref with the same elements as the original.
shift()
Removes an element from the start of the array and returns it.
shuffle()
Returns the array in a random order; can be called in list context or scalar context and will return an arrayref in the latter case.
shuffle_in_place()
Rearranges the array in a random order, and changes the original value to point to the new order.
sort( $coderef? )
Arguments: Optional[CodeRef].
Like sort from perlfunc.
sort
sort_in_place( $coderef? )
Like sort from perlfunc, but changes the original value to point to the newly sorted array.
splice( $index, $length, @values )
Like splice from perlfunc.
splice
sum()
Like List::Util::sum0().
List::Util::sum0()
tail( $count )
Returns the last $count elements of the array in list context.
uniq()
Returns the array filtered to remove duplicates; can be called in list context or scalar context and will return an arrayref in the latter case.
uniq_in_place()
Filters the array to remove duplicates, and changes the original value to point to the filtered array.
uniqnum()
Returns the array filtered to remove duplicates numerically; can be called in list context or scalar context and will return an arrayref in the latter case.
uniqnum_in_place()
Filters the array to remove duplicates numerically, and changes the original value to point to the filtered array.
uniqstr()
Returns the array filtered to remove duplicates stringwise; can be called in list context or scalar context and will return an arrayref in the latter case.
uniqstr_in_place()
Filters the array to remove duplicates stringwise, and changes the original value to point to the filtered array.
unshift( @values )
Adds an element to the start of the array.
No functions are exported by this module by default. To import them all (this is usually a bad idea), use:
use Hydrogen::Topic::ArrayRef -all;
To import a particular function, use:
use Hydrogen::Topic::ArrayRef 'all_true';
To rename functions:
use Hydrogen::Topic::ArrayRef 'all_true' => { -as => 'myfunc' };
On Perl 5.37.2+, you can import lexically:
use Hydrogen::Topic::ArrayRef -lexical, 'all_true';
See Exporter::Tiny::Manual::Importing for more hints on importing.
Please report any bugs to http://github.com/tobyink/p5-hydrogen/issues.
Hydrogen, Hydrogen::ArrayRef, Hydrogen::Array, Hydrogen::Curry::ArrayRef, Sub::HandlesVia::HandlerLibrary::Array, List::Util, List::MoreUtils.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2022 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
To install Hydrogen, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Hydrogen
CPAN shell
perl -MCPAN -e shell install Hydrogen
For more information on module installation, please visit the detailed CPAN module installation guide.