Talk:Partial function application: Difference between revisions
Content added Content deleted
(→What is partial application?: new section) |
(→Is Scala correct?: Yes, you can pass arity 3 function to map.) |
||
Line 166: | Line 166: | ||
: I've never written any Scala code and only seen a few samples, but this does look like partial application to me (quite similar to Perl 6's Whatever-Star). The fact that you have to mention a type signature might just be a limitation of Scala's type inferencer. The key question is: can you use this to pass an arity 3 function to map without using any intermediate definitions or lambda's? —''[[User:Ruud Koot|Ruud]]'' 07:05, 21 April 2011 (UTC) |
: I've never written any Scala code and only seen a few samples, but this does look like partial application to me (quite similar to Perl 6's Whatever-Star). The fact that you have to mention a type signature might just be a limitation of Scala's type inferencer. The key question is: can you use this to pass an arity 3 function to map without using any intermediate definitions or lambda's? —''[[User:Ruud Koot|Ruud]]'' 07:05, 21 April 2011 (UTC) |
||
:: <lang scala>scala> def f(a: Int, x: Int, b: Int) = a * x + b |
|||
f: (a: Int,x: Int,b: Int)Int |
|||
scala> List(1, 2, 3).map(f(10, _, 1)) |
|||
res4: List[Int] = List(11, 21, 31)</lang> |
|||
:: Yes, you can pass arity 3 function to map. The _ has no type signature. A _ without a type signature can be an error, so I am not sure why it worked here. (I am new to Scala, and not the author of the Scala solution.) --[[User:Kernigh|Kernigh]] 19:00, 21 April 2011 (UTC) |
|||
==Is Lisp correct?== |
==Is Lisp correct?== |