develooper Front page | perl.perl6.users | Postings from July 2019

[golf?] list of matches

Thread Next
From:
Marc Chantreux
Date:
July 9, 2019 21:36
Subject:
[golf?] list of matches
Message ID:
20190709213622.GA6121@prometheus.u-strasbg.fr
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

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About