Jump to content

First-class functions: Difference between revisions

m (→‎{{header|Ruby}}: Line 9 is now line 6.)
Line 478:
foreach (i, f; dir)
writefln("%6.3f", compose!(f, inv[i])(0.5));
}</lang>
 
=={{header|Dart}}==
<lang dart>cube(x) { return x * x * x; }
inv_cube(x) { return Math.pow(x, 1/3); }
 
compo(f1, f2) {
return func(x) { return f1(f2(x));};
}
 
main() {
var funcs = [Math.sin, Math.exp, cube];
var invs = [Math.asin, Math.log, inv_cube];
for (int i = 0; i < 3; i++)
print(compo(funcs[i], invs[i])(1));
}</lang>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.