Last active
November 22, 2020 15:17
-
-
Save julianrubisch/3b171ba750193a7a71d9851ff751d8ed to your computer and use it in GitHub Desktop.
Supercollider Head/Tail Recursion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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