Skip to content

Commit 0816047

Browse files
committed
Move splice() from List to Array
fixes #254
1 parent 1dd77e8 commit 0816047

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

doc/Type/Array.pod

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,26 @@ Usage:
164164
Adds the elements from C<LIST> to the front of the array, modifying it
165165
in-place.
166166
167+
=head2 routine splice
168+
169+
Defined as:
170+
171+
multi sub splice(@list, $start, $elems?, *@replacement) returns Array
172+
multi method splice(Array:D $start, $elems?, *@replacement) returns Array
173+
174+
Usage:
175+
176+
splice(ARRAY, START, ELEMS?, REPLACEMENT?)
177+
ARRAY.splice(START, ELEMS?, REPLACEMENT?)
178+
179+
Deletes C<$elems> elements starting from index C<$start> from the C<Array>,
180+
returns them and replaces them by C<@replacement>. If C<$elems> is omitted,
181+
all the elements starting from index C<$start> are deleted.
182+
183+
Example:
184+
185+
my @foo = <a b c d e f g>;
186+
say @foo.splice(2, 3, <M N O P>); # c d e
187+
say @foo; # a b M N O P f g
188+
167189
=end pod

doc/Type/List.pod

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -754,28 +754,6 @@ I<Note:> In the functional programming world, this operation is generally
754754
called a L<left fold|
755755
https://en.wikipedia.org/wiki/Fold_%28higher-order_function%29#Folds_on_lists>.
756756
757-
=head2 routine splice
758-
759-
Defined as:
760-
761-
multi sub splice(@list, $start, $elems?, *@replacement) returns List:D
762-
multi method splice(List:D: $start, $elems?, *@replacement) returns List:D
763-
764-
Usage:
765-
766-
splice(LIST, START, ELEMS?, REPLACEMENT?)
767-
LIST.splice(START, ELEMS?, REPLACEMENT?)
768-
769-
Deletes C<$elems> elements starting from index C<$start> from the list,
770-
returns them and replaces them by C<@replacement>. If C<$elems> is omitted,
771-
all the elements starting from index C<$start> are deleted.
772-
773-
Example:
774-
775-
my @foo = <a b c d e f g>;
776-
say @foo.splice(2, 3, <M N O P>); # c d e
777-
say @foo; # a b M N O P f g
778-
779757
=head2 routine combinations
780758
781759
Defined as:

0 commit comments

Comments
 (0)