In Scala, the underscore in general is a wildcard character. Here specifically, it is a shorthand for a parameter name. So the lambda expression ap(_)(f)
is equivalent to x => ap(x)(f)
.
You can use _
as shorthand for the parameter(s) of an anonymous function if each parameter is used only once, and they are used in the order of their declaration.