You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While trying to code the Clapping Music piece from Steve Reich I noticed that Mercury actually lacks some method/function/way to allow creating a list iteratively.
The result of the code is currently this:
// the initial rhythm, played 8 timeslistptncopy([111011010110]8)// the repetitions with shifts for every steplistptn2join(ptnrot(ptn-1)rot(ptn-2)rot(ptn-3)rot(ptn-4)rot(ptn-5)rot(ptn-6)rot(ptn-7)rot(ptn-8)rot(ptn-9)rot(ptn-10)rot(ptn-11))
It is clear there is lots of repetition needed in order to be able to rotate the pattern after every 8 duplicates. It would be interesting to see if there is a way to do this without the repetition of the code. For example providing a list on a function argument that would usually only accept a single number could make that function perform it multiple times:
Another option is that there is some kind of for() or iterate()/iter() method, that performance a function iteratively by putting the value from another list as argument. For example:
listptncopy([111011010110]8)// performance the function rot() multiple times for every value of the first list// using i as a placeholder for the value from that listlistptn2iter([0-1-2-3...-11]rot(ptni))
While trying to code the Clapping Music piece from Steve Reich I noticed that Mercury actually lacks some method/function/way to allow creating a list iteratively.
The result of the code is currently this:
It is clear there is lots of repetition needed in order to be able to rotate the pattern after every 8 duplicates. It would be interesting to see if there is a way to do this without the repetition of the code. For example providing a list on a function argument that would usually only accept a single number could make that function perform it multiple times:
This could be written even shorter, by using the
spreadInc()
method:Another option is that there is some kind of
for()
oriterate()/iter()
method, that performance a function iteratively by putting the value from another list as argument. For example:The current result of coding the Clapping Music:
https://mercury-playground.pages.dev/#Ly8gQ2xhcHBpbmcgTXVzaWMgLSBTdGV2ZSBSZWljaCAoMTk3MikKLy8gQW4gYWxnb3JpdGhtaWMgbXVzaWMgcGllY2Ugd2hlcmUgMiBjbGFwcGluZyBwZXJmb3JtZXJzIHN0YXJ0IHdpdGggdGhlIHNhbWUgcmh5dGhtLgovLyBBZnRlciA4IHJlcGV0aXRpb25zIG9mIHRoZSByaHl0aG0gb25lIHBlcmZvcm1lciBzaGlmdHMgdGhlIHBhdHRl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