The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
add() Append other ARRAY to itself.
minus() Remove all elements which other ARRAY contains from itself.
multiply() Duplicate self by a number of times or join all elements by a string.
intersection() Generate an intersection set between self and other ARRAY.
has_all() Check if all elements are defined. When block given, check if all results returned by block are true.
has_any() Check if any element is defined. When block given, check if any result returned by block are true.
assoc() Find the first sub array which contains target object as the first element.
at() Return the element of certain position. Return undef if element is not found.
bsearch() Find the element by certain condition. Return undef if element is not found. Note: The real binary search is not implemented yet.
chunk() Chunk consecutive elements which is under certain condition into [ condition, [ elements... ] ] array.
  ra( 1, 3, 2, 4, 5, 6 )->chunk( sub { $_[0] % 2 } )
  # return [ [ 1, [ 1, 3 ] ], [ 0, [ 2, 4 ] ], [ 1, [5] ], [ 0, [6] ] ]
clear() Clear all elements.
combination() Generate all combinations of certain length n of all elements.
  ra( 1, 2, 3, 4 )->combination(2) # return  [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]] 
  ra( 1, 2, 3 )->combination( 3, sub {
          print $_[0]->to_s;
  } )
  # print "[3, 1, 2]"
compact() Remove all undef elements and store the result in a Ruby::Collections::Array.
  ra( 1, undef, 3, undef, 5 )->compact # return [ 1, 3, 5 ]
compactEx() Remove all undef elements in self.
  ra( 1, undef, 3, undef, 5 )->compact # return [ 1, 3, 5 ]
concat() Append another array to self.
  ra(1, 2, 3)->concat([4, 5]) # return [1, 2, 3, 4, 5]
count() Return the amount of elements
  ra(1, 2, 3)->count() #return 3 
  ra(1, 2, 2)->count(2) #return 2
  ra(1, 2, 3)->count( sub { $_[0] > 0 } ) #return 3
cycle() Calls the block for each element n times. It runs forever, if n is not given.
  ra(1, 2, 3)->cycle(2 , sub { print $_[0] + 1 + ", " })  # print  "2, 3, 4, 2, 3, 4, "
  
  ra(1, 2, 3)->cycle(sub { print $_[0] + 1 + ", " })  # print  "2, 3, 4, 2, 3, 4, .... forever
delete() Delete all the items in self if equal to the given value, and return it.
  ra(1, 3, 5)->delete(3); #return 3
delete_at() Delete the element at the given index, and return it.
  ra(1, 2, 3)->delete_at(2); #return 3
delete_if() Deletes every elements of self if the block evaluates to true.
  ra(1, 2, 3)->delete_if ( sub { |e| e > 2}); #return ra(1, 2)
drop() Drop first n elements in array and return rest elements in a new array.
  ra(1, 3, 5, 7, 9)->drop(3); #return ra(7, 9)
drop_while Drop the elememts up to, but not including, the first element which the block returns false, and return the rest elements as a new array.
  ra(1, 2, 3, 4, 5, 1, 4)->drop_while( sub { $_[0] < 2 } ); #retrun ra( 2, 3, 4, 5, 1, 4 )
each() Passing each element in self as a parameter to the call block. Alias: each_entry()
  ra(1, 2, 3)->each(sub { print $_[0] }); #return ra(1, 2, 3)
each_cons() Group each element with (n-1) following members in to an new array until the last element included.
  ra(1, 2, 3, 4, 5, 6, 7, 8)->each_cons(5); #return ra(ra(1, 2, 3, 4, 5), ra(2, 3, 4, 5, 6), ra(3, 4, 5, 6, 7), ra(4, 5, 6, 7, 8))
each_entry() Passing each element in self as a parameter to the call block. Alias: each()
  ra(1, 2, 3)->each_entry(sub { print $_[0] }); #return ra(1, 2, 3)
each_index Passing the index of each element to the block.
  ra(1, 3, 5, 7)->each_index( sub { print $_[0] } ); # print 0123
each_slice Group element with (n-1) members in to an new array until the last element included.
  ra(1, 2, 3, 4, 5)->each_slice(3); #return ra(ra(1, 2, 3), ra(4, 5));
each_with_index For each item calls block with itself and it's index.
  ra(1, 2, 3)->each_with_index(sub { $_[1] }); #return ra(0, 1, 2)
each_with_object Passing each element with an object in a block, return the object in the end.
  ra( 1, 2, 3 )->each_with_object( ra, sub { $_[1] << $_[0]**2 } ); #return ra( 1, 4, 9 )
  
is_empty Return true if the array don't contain any element.
  ra(1, 2, 3)->is_empty() #return 0;
eql Return true if these 2 arrays have same order and content.
  ra(1, 2, 3)->equal(ra(4, 5, 6)) #return 0
not_eql Return true if these 2 arrays have different order and content.
  ra(1, 2, 3)->not_equal(ra(4, 5, 6)) #return 1
fetch() Retrun the element of array from given index. If the given index is out of the scalar of array, it will be seen as an IndexError exception, unless a second argument is given, and which will be a default value. If a block is given, it will be executed when an invalid index is given. If the index is a negative value, the last element of array will be return.
  ra(1, 2, 3)->fetch(2) #return 3;
  ra(1, 2, 3)->fetch(5, 6) #return 6;
  ra(1, 2, 3)->fetch(-1) #return 3;
fill Replace all the elements in array by the given value. If the second and third(n) value are given in the same time, means the array will be replace by the given value from the second value of index to the following n elements. If a block is given, it will pass all or given amount of indexs to the block and return the result as an array.
  ra(1, 2, 3)->fill(4) #return ra(4, 4, 4);
  ra(1, 2, 3, 4)->fill(sub {$_[0]}) #return ra(0, 1, 2, 3);
  ra(1, 2, 3, 4)->fill(1, sub { 11 }) #return ra(1, 11, 11, 11);
  ra(1, 2, 3, 4)->fill('ab', 1) #return ra(1, 'ab', 'ab', 'ab');
  ra(1, 2, 3, 4)->fill(1, 2, sub { 11 }) #return ra(1, 11, 11, 4);
  ra(1, 2, 3, 4)->fill('ab', 1, 2) #return ra(1, 'ab', 'ab', 4);
find Passing each element to the block, and return the first element if block is true, else return undef.
  ra('a', 'b', 'c', 'b')->find(sub { $_[0] eq 'b' }) return b;
find_index Return the first index of the given value in the array. If a block instead of an argument, then return the first index of the given value in the array.
  ra('a', 'b', 'c', 'b')->find_index('b') #return 1;
  ra('a', 'b', 'c', 'b')->find_index( sub { if($_[0] eq 'b')}) #return 1;
index Retrun the first index of given object in array.
  ra('a', 'b', 'c', 'c')->index('c') #return 2; 
inject Combines all elements by applying a binary operation, ex. a block, method or operator.
  ra(1, 2, 3, 4)->inject(sub { $_[0] + $_[1] }) #return 10;
first Return the first or first n elements of the array. Return the first n elements of the array as a new array.
  ra(1, 2, 3 ,4)->first #return 1
  ra(1, 2, 3 ,4)->first(2) #return ra(1, 2)
flat_map() Return a new array with the concatenated result of each element's running block.
  ra(ra('a', 'b', 'c'), ra('d', 'e'))->flat_map(sub {$_[0] + ra('f')}) #return ra('a', 'b', 'c', 'f', 'd', 'e', 'f');
flatten Return a new array after flattening self into one-dimension.
 ra(ra('a', 'b'), ra('d', 'e'))->flatten #return ra('a', 'b', 'd', 'e');
recursive_flatten
flattenEx() Flattens self in place.
  ra(ra('a', 'b'), ra('d', 'e'))->flattenEx #return ra('a', 'b', 'd', 'e');
grep() Return all the elements as an array which matches the given pattern. If a block is supplied, each matching element will be passed to the block, and the result will be collect in an array.
  ra('abbc', 'qubbn', 'accd')->grep('bb') #return ra('abbc', 'qubbn')
  ra('abbc', 'qubbn', 'accd')->grep('bb', sub { $_[0] + 'l'}) #return ra('abbcl', 'qubbnl')
  ra(1, 2, 3, 4)->group_by( sub { $_[0]%3 }) #return rh( 1=>[1, 4], 2=>[2], 0=>[3]);
  ra(1, 3, 5, 7, 9)->include(9) #return true #
replace() Replace all elements of self by the other elements of given array.
  ra(1, 4, 6)->replace(ra(2, 5)) #return ra(2, 5);
insert() Insert the given value at the given index.
  ra(1, 2, 3, 4)->insert(2, 5) #return ra(1, 2, 5, 3, 4);
  ra(1, 2, 3 ,4)->insert(-2, 5) #return ra(1, 2, 3, 5, 4);#
inspect() Return the object as string.
  ra(1, 2, 3)->inspect() #return 'ra(1, 2, 3)'; #
to_s() ra(1, 2, 3)->inspect() #return 'ra(1, 2, 3)';
join() Return a string created by converting each element of array to a string, merged by the given separator.
  ra('a', 'b', 'c')->join("/") #return 'a/b/c';
keep_if() Delete the element of self for which the given block evaluates to false.
  ra(1, 2, 3)->keep_if(sub {$_[0] > 2}) #return ra(3);
last() Return the last or last n elements of self.
  ra(1, 2, 3)->last #return 3;
  ra(1, 2, 3)->last(2) #return ra(2, 3);
length() Retrun the number of elements of self.
  ra(1, 2, 3)->length() #return 3;
  ra()->length() #return 0;
map() Transform each element and store them into a new Ruby::Collections::Array. Alias: collect()
mapEx() Transform each element and store them in self. Alias: collectEx()
max() Return the max value of object. If a block is given,
  ra(1, 2, 3)->max() #return 3;
  ra(1, 2, 3)->max(sub {$_[1] <=> $_[0]}) #return 1;
max_by() Return the object that gives the maximum value from the given block.
  ra('avv', 'aldivj', 'kgml')->max_by(sub {length($_[0])}) #return 'aldivj';
min() Return the min value of object. If a block is given,
  ra(1, 2, 3)->min() #return 1;
  ra(1, 2, 3)->min(sub {$_[1] <=> $_[0]}) #return 3;
min_by() Return the object that gives the minimum value from the given block.
  ra('kv', 'aldivj', 'kgml')->min_by(sub {length($_[0])}) #return 'kv';
minmax() Return an array which contains the minimum and maximum value.
  ra(1, 2, 3)->minmax #return ra(1, 3);
  ra('bbb', 'foekvv', 'rd')->minmax(sub{length($_[0]) <=> length($_[1])}) #return ra('rd', 'foekvv'); 
minmax_by() Return an array which contains the objects that correspond to the minimum and maximum value respectively from the given block.
  ra('heard', 'see', 'thinking')->minmax_by(sub {length($_[0])}) #return ra('see', 'thinking');
has_none() Pass each element to the given block, this method returns true if the block never returns true for all elements. If the block is not given, this method returns true if all the elements are flase.
  ra(99, 43, 65)->has_none(sub {$_[0] < 50}) #return 0;
  ra()->has_none #return 1;
has_one() Pass each element to the given block, this method returns true if the block returns true exactly once. If the block is not given, this method returns true if only one elements is true.
  ra(99, 43, 65)->has_one(sub {$_[0] < 50}) #return 1;
  ra(100)->has_one #return 1;
partition() Return an array which contains two elements. The first are the objects which evaluate the block to true. The second are the rest.
  ra(1, 2, 3, 4, 5, 6, 7)->partition(sub {$_[0] % 2 == 0}) #return ra(ra(2, 4, 6), ra(1, 3, 5, 7));
permutation() If a block is given, then return self as all kind of permutations. If a parameter(n) is given, and also a block, then return self as all kind of permutations in length n. If a block is not given, then return
  ra(1, 2, 3)->permutation()
pop() Return the last element. If a number n is given, then return the last n elements as an array.
  ra(1, 2, 3)->pop #return 3;
  ra(1, 2, 3)->pop(2) #return ra(2, 3);
product() Return an array of all combinations of all arrays. #block
  ra(1, 2)->product(ra(2,3)) #return ra(ra(1, 2), ra(1, 3), ra(2, 2), ra(2, 3));
push() Appending the given array to self, then return it.
  ra(1, 2, 3)->push(5, 6) #return ra(1, 2, 3, 5, 6);
double_left_arrows() Alias : push()
rassoc() Returns the first array which contains the target object as the last element.
  ra(ra(1, 3), 3, ra(2, 3))->rassoc(3) #returns ra(1, 3);
reject() Return a new array contains the elements from self for which the given block is not true. Alias: delete_if()
  ra(1, 2, 3)->reject(sub { $_[0] < 3 }) #return ra(3);
rejectEx() Delete all the elements from self for which the given block is true.
  ra(1, 2, 3)->rejectEx(sub { $_[0] < 3 }) #return ra(3);
repeated_combination() Returns the array which lists all the repeated combinations of length n of all elements from array.
  ra(1, 2, 3)->repeated_combination(2) #returns ra(ra(1, 1), ra(1, 2), ra(1, 3), ra(2, 2), ra(2, 3), ra(3, 3));
increase_repeated_combination_loop_counter()
repeated_permutation() Returns the array which lists all the repeated permutations of length n of all elements from array.
  ra(1, 2)->repeated_permutation(2) #returns ra(ra(1, 1), ra(1, 2), ra(2, 1), ra(2, 2));
reverse() Returns a new array which contains self's elements in the reverse order.
  ra(1, 2, 3)->reverse() #returns ra(3, 2, 1);
reverseEx() Returns self where all the elements list in the reverse order.
  ra(1, 2, 3)->reverseEx() #returns ra(3, 2, 1);
reverse_each() Passing all the elements to the block, but in the reverse order.
  ra(1, 2, 3)->reverse_each(sub {$_[0]}) #returns ra(3, 2, 1);
rindex() Returns the index of last object which equal to given object. If a block is given, returns the index of the last object for which the block returns true.
  ra(1, 2, 3, 2, 4)->rindex(2) #returns 3;
  ra(1, 2, 3, 2, 4)->rindex(sub {$_[0] == 2}) #returns 3;
rotate() Returns a new array by rotating self, the element at given number is the first element of new array. If the given number is negative, then statring from the end of self.
  ra(1, 2, 3)->rotate() #return ra(2, 3, 1);
  ra(1, 2, 3)->rotate(2) #return ra(3, 1, 2);
  ra(1, 2, 3)->rotate(-2) #return ra(2, 3, 1);
rotateEx() See rotate, but return self inplace.
sample() Chooses a random element or n random elements from the array.
  ra(1, 2, 3, 4)->sample 
  ra(1, 2, 3, 4)->sample(2)
select() Returns a new array which contains all the elements for which the given block returns true.
 ra(1, 4, 6, 7, 8)->select(sub {($_[0]%2) == 0 }) #return ra(4, 6, 8);
selectEx() Deleting all the elements from self for which the given block returns false, then returns self. Alias : keep_if
  ra(1, 4, 6, 7, 8)->selectEx(sub {($_[0]%2) == 0 }) #return ra(4, 6, 8);
shift() Removes the first element of self and returns it. If a number n is given, then removes the first n element of self and returns them as an array.
  ra(1, 2, 3)->shift #returns 1;
  ra(1, 2, 3, 4, 5)->shift(3) #returns ra(1, 2, 3);
unshift() Adding the objects to the front of self.
  ra(2, 4, 6)->unshift(1, 3, 5) #returns ra(1, 3, 5, 2, 4 ,6);
shuffle() Returns a new array with all elements of self shuffled.
  ra(1, 2, 3, 4, 5, 6)->shuffle 
shuffleEx() Shuffles all elements in self in place.
  ra(1, 2, 3, 4, 5, 6)->shuffleEx  
slice() Returns the element at given index. If the start and length(n) are given, then returns a new array contains the elements from the start index to following n-1 elements.
  ra(1, 2, 3)->slice(2) #returns 3;
  ra(1, 2, 3, 4, 5)->slice(1, 2) #returns ra(2, 3);
sliceEx() Deleting the element at given index from self, then return this element. Or deleting the elements from given start index to following n-1 elements from self, then return these elements.
  ra(1, 2, 3)->slice(2) #returns 3;
  ra(1, 2, 3, 4, 5)->slice(1, 2) #returns ra(2, 3);
slice_before() Creates a new array for each chuncked elements, the method of chunks could by pattern or block.
  ra(1, 2, 3, 4, 5, 3)->slice_before(3) #returns ra(ra(1, 2), ra(3, 4, 5),ra(3));
  ra(1, 2, 3, 4, 5, 3)->slice_before(sub {$_[0]%3 == 0}) #returns ra(ra(1, 2), ra(3, 4, 5),ra(3));
sort() Returns a new array by sorting self.
  ra(1, 3, 5, 2, 7, 0)->sort #returns ra(0, 1, 2, 3, 5, 7);
  ra('djh', 'kdirhf', 'a')->sort(sub {length($_[0]) <=> length($_[1])}) #returns ra('a', 'djh', 'kdirhf');
sortEx() Sorts self in place.
  ra(1, 3, 5, 2, 7, 0)->sortEx #returns ra(0, 1, 2, 3, 5, 7);
  ra('djh', 'kdirhf', 'a')->sortEx(sub {length($_[0]) <=> length($_[1])}) #returns ra('a', 'djh', 'kdirhf');
sort_by() Returns a new array by sorting self with block method.
  ra(2, 3, 7, 89, 6)->sort_by(sub {$_[0]-2}) #returns ra(2, 3, 6, 7, 89);
sort_byEx() Sorting self with block method, and return self.
  ra(2, 3, 7, 89, 6)->sort_byEx(sub {$_[0]-2}) #returns ra(2, 3, 6, 7, 89);
take() Takes the first n elements from the array.
  ra(3, 5, 6, 7, 8, 9)->take(2) #returns ra(3, 5);
take_while() Passes all elements to the block until the block is false, then returns the previous elements.
  ra(2, 4, 3 ,6 ,7 , 8, 2)->take_while(sub {$_[0] < 5}) #returns ra(2, 4, 3);
to_a() Returns self.
  ra(2, 4, 6, 7, 8, 9)->to_a #returns ra(2, 4, 6, 7, 8, 9);
entries() Returns an array containing all elements.
  rh(2=>4, 4=>5, 6=>7)->entries #returns ra(ra(2, 4),ra(4, 5) ,ra(6, 7));
zip() Converts all arguments into array, and merges each arrays with self by corresponding index.
  my $a = ra(1, 2, 3);
  my $b = ra(4, 5, 6);
  my $c = ra(7, 8);
  $a->zip($b) #returns ra(ra(1, 4), ra(2, 5), ra(3, 6));
  $a->zip($c) #returns ra(ra(1, 7), ra(2, 8), ra(3, undef));
union() Returns a new array by joining with given array, and removing the duplicate elements.
  ra(1, 3, 4)->union(ra(2, 4, 6)) #returns ra(1, 3, 4, 2, 6);

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 26:

'=item' outside of any '=over'

=over without closing =back

Around line 1191:

Unknown directive: =iten