let melody = slow 6 $"0 2 [4 8 .] [3 4 3] 8 4 9"   do cps (86/60/2) d9$ midicmd "midiClock*48" # s "midi"   d9 $midicmd "start" # s "midi"   d4 --$ rev \n $note ((scaleP scalePattern --$ off 4 ((+ 2 ).slow 2) \n -- $off 1 (inversion.slow 2) \n$(rotR 1.5 ) $(+ slow 8 "x" <~> generateMelodicSeed) --$ inversion \n \$ generateMelodicSeed ))#s "[pe-gtr:12,midi]" #gain 1.2 #orbit 3 #midichan 4 

Closures

Closures are a way of treating a function as an object. Functional language generally let the programmer define anonymous functions that “enclose” data that is needed for their function. These functions can then be composed with others to form larger structure. For example, consider the following js function:

function saySomthing(something) {
return ()=>"say" + " " + something;
}


The function saySomething “encloses” the value something and then returns a function that, when called returns the value of something concatenated with the string “say”.

Notes mentioning this note

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.