14 lines
316 B
Plaintext
14 lines
316 B
Plaintext
import math
|
|
|
|
function compose (f, g) {
|
|
return function (x) { return f(g(x)) }
|
|
}
|
|
|
|
var fn = [Math.sin, Math.cos, function(x) { return x*x*x }]
|
|
var inv = [Math.asin, Math.acos, function(x) { return Math.pow(x, 1.0/3) }]
|
|
|
|
for (var i=0; i<3; i++) {
|
|
var f = compose(inv[i], fn[i])
|
|
println(f(0.5)) // 0.5
|
|
}
|