d2 $ note ((scaleP scalePattern $ (rotR 3.5) -- $ inversion \n $ (+ slow 8 "x" <~> ((0.5 ~>) generateMelodicSeed)) -- $ slow 2 \n $ generateMelodicSeed ) - 12)#s "[pe-gtr:9,midi]" #gain 1.2 #orbit 1 #midichan 2 d2 $ note ((scaleP scalePattern $ (rotR 3.5) -- $ inversion \n $ (+ slow 8 "x" <~> ((0.5 ~>) generateMelodicSeed)) -- $ slow 2 \n $ generateMelodicSeed ) - 12)#s "[pe-gtr:9,midi]" #gain 1.2 #orbit 1 #midichan 2 let melody = slow 6 $ "0 2 [4 8 .] [3 4 3] 8 4 9" d9 $ midicmd "start" # s "midi"
index > /home/xinniw/Documents/garden/Closures.md

Closures

:cc0: Closures are a way of treating a function as an object. Functional languages 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".


index > /home/xinniw/Documents/garden/Closures.md