Euclidean rhythm: Difference between revisions
Content added Content deleted
(Add C# implementation) |
(added Raku programming solution) |
||
Line 721: | Line 721: | ||
1001010010100 |
1001010010100 |
||
</pre> |
</pre> |
||
=={{header|Raku}}== |
|||
{{trans|Perl}} |
|||
<syntaxhighlight lang="raku" line># 20240208 Raku programming solution |
|||
say sub ($k is copy, $n is copy) { |
|||
my @s = [ [1] xx $k ].append: [0] xx ($n - $k); |
|||
my $z = my $d = $n - $k; |
|||
($k, $n) = ($d, $k).minmax.bounds; |
|||
while $z > 0 || $k > 1 { |
|||
^$k .map: { @s[$_].append: |@s[*-1 - $_] } |
|||
@s.splice(*-$k); |
|||
($z, $d) = ($z, $n) >>->> $k; |
|||
($k, $n) = ($d, $k).minmax.bounds; |
|||
} |
|||
return [~] @s>>.List.flat; |
|||
}(5, 13);</syntaxhighlight> |
|||
You may [https://ato.pxeger.com/run?1=jZFNboMwEIXVLad4Cy9MBFZQVakKqpUD5AaIRE4gqhUgCIMChPQi3WTRXqqn6TiAuq034_l5fp88n1-VOjX3-3dTH_3Xn6eLUR1MswdnJ2iDw7nsPLBivru4OgDyDmuDN0SIghhtC5qOhSrLtEhWiJaPGieZTx03xKRhPWlsTChO3dD2yM26uFTmLPGsSOS6yFUr9uemSEzo2LHLu85S-4rEEsNgXSWCEYnOlnKRq3KFK-FFbPeHNFC-8APruItxmwRrI0yZ6UPKF77lnMqc9YSQjDT9CCalL-WM-z9imnoYVWndVAWij5gMpRQbbWpxzFQdOjf-4iF4dsPx_6c1zOv4BQ Attempt This Online!] |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |