Help language development. Donate to The Perl Foundation
Generated from DoublePlus.rakumod, then manually edited.
use List::Operator::DoublePlus; # Concatenate two lists together my @l = @l1 ++ @l2; my @l' = @l1 ⧺ @l2; # The operator also works with Arrays and Slips
++ operator to join or concatenate two lists together. The operator
⧺ is also exported as its Unicode counterpart.
concat subroutine that implements the operator's functionality is exported on demand using the
This module is inspired by Aaron Sherman's
Operator::Listcat which defines an infix
listcat operator, as well as the infix
⊕ (CIRCLED PLUS) Unicode alias.
The operator form of
The Unicode operator variant of
multi sub concat(@a, @b --> List) multi sub concat(Slip \a, Slip \b --> Slip) multi sub concat(Array \a, Array \b --> Array)
.Slip (which calls
.list) on both arguments and applies the infix
, operator to join them into a list.
For Slips, it returns a new Slip instead of a List.
For Arrays, it calls
.append on the first parameter with the second parameter as its argument, and returns the combined array.
This subroutine also works for Seqs and any class that does PositionalBindFailover.
Same as :op, it exports the ++ operator and its Unicode counterpart ⧺.
Exports the ++ operator and its Unicode counterpart ⧺.
concat subroutine which implements the operator's functionality.
Only exports the
Only exports the Unicode
The double plus was chosen as the list concatenation operator due to its similarity to the
+ operator applied to lists in Python an other languages. The
++ operator is also used to concatenate lists in Elixir, Haskell, and Scala.
++ was chosen over the
@ operator used in OCaml as I thought it would be too close to the
@ sigil. The Unicode counterpart ⧺ was inspired by this StackExchange question: Is there a common symbol for concatenating two (finite) sequences?
Licensed under the Artistic License 2.0.
Operator::Listcat, the module this was inspired by.