On Tue, Jul 09, 2019 at 11:44:07PM +0200, Laurent Rosenfeld via perl6-users
wrote:
> You might want to take a look at the cross ("X") operator, which takes two
> or more lists as arguments and returns a list or all lists that can be
> constructed combining the elements of each list (or, in other words, a
> Cartesian product of the input lists).
I used it in my first solution which was
sub vs (@xs ( $head, *@tail ) ) {
|($head X @tail),
|(vs @tail if +@tail)
}
if i do @xs X @xs, i have +@xs unexpected elements so i have to filter
the result:
my @players = <jean marc quentin alexandre >;
for @players X @players ==> grep({ [ne] |$_})
-> ( $a , $b ) { say "$a vs $b" }
this is shorter but i my first solution doesn't need to be filtered.
regards
marc