Skip to content

Instantly share code, notes, and snippets.

@julianrubisch
Last active November 22, 2020 15:17
Show Gist options
  • Save julianrubisch/3b171ba750193a7a71d9851ff751d8ed to your computer and use it in GitHub Desktop.
Save julianrubisch/3b171ba750193a7a71d9851ff751d8ed to your computer and use it in GitHub Desktop.
Supercollider Head/Tail Recursion
// head tail recursion in SuperCollider
(
~array = Array.exprand(5, 30, 300).round;
f = {
|array, acc|
if(array.isEmpty,
acc,
{
var head;
head = array.removeAt(0);
acc = acc + head;
f.(array, acc);
}
)
};
~array.postln;
f.(~array, 0).postln;
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment