Ramsey's theorem: Difference between revisions
Content added Content deleted
SqrtNegInf (talk | contribs) (Added Perl example) |
SqrtNegInf (talk | contribs) m (→{{header|Perl 6}}: .Array work-around now obsolete, factored out array-size constant) |
||
Line 946: | Line 946: | ||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |
||
{{Works with|rakudo| |
{{Works with|rakudo|2018.08}} |
||
<lang perl6>my |
<lang perl6>my $n = 17; |
||
@a |
my @a = [ 0 xx $n ] xx $n; |
||
@a[$_;$_] = '-' for ^$n; |
|||
for flat ^ |
for flat ^$n X 1,2,4,8 -> $i, $k { |
||
my $j = ($i + $k) % |
my $j = ($i + $k) % $n; |
||
@a[$i;$j] = @a[$j;$i] = 1; |
@a[$i;$j] = @a[$j;$i] = 1; |
||
} |
} |
||
.say for @a; |
.say for @a; |
||
for combinations( |
for combinations($n,4) -> $quartet { |
||
my $links = [+] $quartet.combinations(2).map: -> $i,$j { @a[$i;$j] } |
my $links = [+] $quartet.combinations(2).map: -> $i,$j { @a[$i;$j] } |
||
die "Bogus!" unless 0 < $links < 6; |
die "Bogus!" unless 0 < $links < 6; |