16 lines
333 B
Plaintext
16 lines
333 B
Plaintext
func compose(f,g) {
|
|
func (*args) {
|
|
f(g(args...));
|
|
}
|
|
}
|
|
|
|
var cube = func(a) { a.pow(3) };
|
|
var croot = func(a) { a.root(3) };
|
|
|
|
var flist1 = [Math.method(:sin), Math.method(:cos), cube];
|
|
var flist2 = [Math.method(:asin), Math.method(:acos), croot];
|
|
|
|
flist1.range.each { |i|
|
|
say compose(flist1[i], flist2[i])(0.5);
|
|
}
|