Euclidean rhythm: Difference between revisions

Added Quackery.
(Added C++.)
(Added Quackery.)
 
Line 1,226:
 
</syntaxhighlight>
 
=={{header|Quackery}}==
 
Uses an alternative algorithm described in the YouTube video [https://youtu.be/8-vakfQ-qlk How to Calculate Euclidean Rhythms by Hand]. This gives results which are equivalent under rotation to those given by the algorithm described by Toussaint. (As the paper notes, "since the sequence is cyclic it does not matter".)
 
<syntaxhighlight lang="Quackery"> [ dup temp put
[] swap 1+ times
[ i^ 1 - join ]
[] unrot
witheach
[ over *
temp share mod
rot join swap ]
drop
temp release
[] swap
behead swap
witheach
[ tuck <
rot join swap ]
drop ] is rhythm ( n n --> [ )
 
3 8 rhythm echo cr
5 13 rhythm echo cr</syntaxhighlight>
 
{{out}}
 
<pre>[ 1 0 0 1 0 0 1 0 ]
[ 1 0 0 1 0 0 1 0 1 0 0 1 0 ]
</pre>
 
=={{header|R}}==
1,488

edits