Re: [golf?] list of matches
hello Bruce; > # Elegant using the "cat-ears" range modifiers in Perl 6: > for 0 ..^ @players.end -> \i { > for i ^.. @players.end -> \j { > say @players[i,j].join(' vs '); > } > } > # See https://docs.perl6.org/type/Range i played around it and got: my @players = ; my @rounds = gather for ^@players -> \p { take @players[p,$_] for p^..^@players }; for @rounds -> ( $a, $b ) { "$a vs $b".say } > say .join(' vs ') for @players.combinations(2); > # See https://docs.perl6.org/routine/combinations i knew there will be something like that ... but didn't find it! thank you very much. regards marc
Re: [golf?] list of matches
> On Jul 10, 2019, at 12:17 PM, Marc Chantreux wrote: —snip-- > my @rounds = >gather for ^@players -> \p > { take @players[p,$_] for p^..^@players }; Cool. Yet another way to do it: my @rounds = @players.kv.map: -> \k1, \p1 { |@players.skip(1 + k1).map: -> \p2 { p1, p2 } } I mention it because I had not though to use .skip for this purpose until today. > thank you very much. You are very welcome. — Bruce Gray (Util of PerlMonks)