Euclidean rhythm: Difference between revisions
Content added Content deleted
imported>CosmiaNebula (python) |
(Added Easylang) |
||
Line 16: | Line 16: | ||
** 10010 10010 100 | |
** 10010 10010 100 | |
||
* At this point, we can continue the algorithm until only one form remains, but notice that one of the groups has only one element [100], so the algorithm can actually terminate right here and output the concatenation 1001010010100. |
* At this point, we can continue the algorithm until only one form remains, but notice that one of the groups has only one element [100], so the algorithm can actually terminate right here and output the concatenation 1001010010100. |
||
=={{header|EasyLang}}== |
|||
{{trans|JavaScript}} |
|||
<syntaxhighlight> |
|||
func$ euclrhythm k n . |
|||
for i to n |
|||
h = if i <= k |
|||
s[][] &= [ h ] |
|||
. |
|||
d = n - k |
|||
n = higher k d |
|||
k = lower k d |
|||
z = d |
|||
while z > 0 or k > 1 |
|||
for i to k |
|||
for c in s[len s[][] + 1 - i][] |
|||
s[i][] &= c |
|||
. |
|||
. |
|||
len s[][] -k |
|||
z = z - k |
|||
d = n - k |
|||
n = higher k d |
|||
k = lower k d |
|||
. |
|||
for i to len s[][] |
|||
for v in s[i][] |
|||
r$ &= v |
|||
. |
|||
. |
|||
return r$ |
|||
. |
|||
print euclrhythm 3 8 |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
10010010 |
|||
</pre> |
|||
== [[Python]] == |
== [[Python]] == |