Currying: Difference between revisions
Content added Content deleted
m (https://github.com/dlang/phobos/pull/1979) |
(Added Kotlin) |
||
Line 861: | Line 861: | ||
We can now use plus5 as a filter, e.g.<lang jq>3 | plus5</lang> produces 8. |
We can now use plus5 as a filter, e.g.<lang jq>3 | plus5</lang> produces 8. |
||
=={{header|Kotlin}}== |
|||
<lang scala>// version 1.1.1 |
|||
fun curriedAdd(x: Int) = { y: Int -> x + y } |
|||
fun main(args: Array<String>) { |
|||
val a = 2 |
|||
val b = 3 |
|||
val sum = curriedAdd(a)(b) |
|||
println("$a + $b = $sum") |
|||
}</lang> |
|||
{{out}} |
|||
<pre> |
|||
2 + 3 = 5 |
|||
</pre> |
|||
=={{header|LFE}}== |
=={{header|LFE}}== |