Currying IMO - Scala. , wikipedia,
, ( ) , .
, f(a, b, c) f(a)(b)(c). Scala? . , . f ( Scala ) Int => (Int => (Double => (Double => Double))). f:
scala> def f(a: Int)(b: Int)(c: Double)(d: Double): Double = a * c + b * d
f: (a: Int)(b: Int)(c: Double)(d: Double)Double
, . . , . , . :
scala> f(0)
<console>:01: error: missing argument list for method f
Unapplied methods are only converted to functions when a function type is expected.
You can make this conversion explicit by writing `f _` or `f(_)(_)(_)(_)` instead of `f`.
, , : f(0) Scala eta-, , :
scala> val fl: (Int => (Double => (Double => Double))) = f(0)
fl: Int => (Double => (Double => Double)) = $$Lambda$1342/937956960@43c1614
eta- :
scala> val fl: (Int => (Double => (Double => Double))) = (b => (c => (d => f(0)(b)(c)(d))))
fl: Int => (Double => (Double => Double)) = $$Lambda$1353/799716194@52048150
() curries - placeholder ( ):
scala> f _
res11: Int => (Int => (Double => (Double => Double))) = $$Lambda$1354/1675405592@4fa649d8
scala> f(0) _
res12: Int => (Double => (Double => Double)) = $$Lambda$1355/1947050122@ba9f744
, :
def g: Int => (Double => (Double => Double)) = f(0)
def g: Int => (Double => (Double => Double)) = (b => (c => (d => f(0)(b)(c)(d))))
. g, " " . , g(0) " g , 0".