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).

Cheers,
Laurent.


Le mar. 9 juil. 2019 à 23:36, Marc Chantreux <e...@phear.org> a écrit :

> hello people,
>
> i have a game where every opponent much play every other ones
> so i implemented vs to get a list of all the matches from a list
> of opponents.
>
> i'm pretty sure that there is a shorter/more beautiful solution than
> mine so i really would like to see.
>
> mine is
>
>   sub vs (@xs ( $head, *@tail ) ) {
>     |($head X @tail),
>     |(vs @tail if +@tail)
>   }
>
>   my @rounds = <jean marc quentin alexandre marie-france ludo >.&vs;
>
>   for @rounds -> ( $a, $b )  { say "$a vs $b" };
>
> anyone want to share?
>
> regards,
> marc
>

Reply via email to