Jump to content

First-class functions/Use numbers analogously: Difference between revisions

no edit summary
m (added whitespace before the table of contents (TOC).)
No edit summary
Line 936:
}
}</lang>
 
=={{header|Never}}==
<lang Never>
func multiplier(a : float, b : float) -> (float) -> float {
let func(m : float) -> float { a * b * m }
}
 
func main() -> int {
var x = 2.0;
var xi = 0.5;
var y = 4.0;
var yi = 0.25;
var z = x + y;
var zi = 1.0 / z;
 
var f = [ x, y, z ] : float;
var i = [ xi, yi, zi ] : float;
var c = 0;
var mult = let func(m : float) -> float { 0.0 };
for (c = 0; c < 3; c = c + 1) {
mult = multiplier(f[c], i[c]);
prints(f[c] + " * " + i[c] + " * " + 1.0 + " = " + mult(1) + "\n")
};
 
0
}
</lang>
{{output}}
<pre>
2.00 * 0.50 * 1.00 = 1.00
4.00 * 0.25 * 1.00 = 1.00
6.00 * 0.17 * 1.00 = 1.00
</pre>
 
=={{header|Objeck}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.