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

Added Kotlin
(→‎{{header|Rust}}: Use blowfish operator)
(Added Kotlin)
Line 704:
 
As of this writing, there is no entry for jq at [[First-class functions]].
 
=={{header|Kotlin}}==
<lang scala>// version 1.1.1
 
fun multiplier(n1: Double, n2: Double) = { m: Double -> n1 * n2 * m}
 
fun main(args: Array<String>) {
val x = 2.0
val xi = 0.5
val y = 4.0
val yi = 0.25
val z = x + y
val zi = 1.0 / ( x + y)
val a = doubleArrayOf(x, y, z)
val ai = doubleArrayOf(xi, yi, zi)
val m = 0.5
for (i in 0 until a.size) {
println("${multiplier(a[i], ai[i])(m)} = multiplier(${a[i]}, ${ai[i]})($m)")
}
}</lang>
 
{{out}}
<pre>
0.5 = multiplier(2.0, 0.5)(0.5)
0.5 = multiplier(4.0, 0.25)(0.5)
0.5 = multiplier(6.0, 0.16666666666666666)(0.5)
</pre>
 
=={{header|Lua}}==
9,479

edits