Reputation: 531
In Perl the ,
operator can be used to concatenate Lists; however, Perl 6 does not flatten Lists in this context resulting in a List of two Lists. Concatenating the Lists requires using |
, the slip operator.
my @a = <a b c>;
my @b = <d e f>;
my @ab = |@a, |@b;
Is there any shorthand for this operation?
Upvotes: 11
Views: 789
Reputation: 4329
You can use the "flat" sub for this:
my @a = <a b c>;
my @b = <d e f>;
my @ab = flat @a, @b;
say @ab.perl; #> ["a", "b", "c", "d", "e", "f"]
my @abf = (@a, @b).flat;
say @abf.perl; #> ["a", "b", "c", "d", "e", "f"]
Upvotes: 14