A small example as a complement to my previous post:

my @a = 1, 2;
my @b = 3, 4;
my @c = @a X @b;       # -> [(1,3), (1,4), (2,3), (2,4)]



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