Scala: Partial application

val multiply: (Int, Int, Int) => Int 
= (n1 , n2, n3) => n1 * n2 * n3
val tenTimesProduct = multiply(10,_,_)
val fiveHundredTimes = tenTimesProduct(50,_)
println(multiply(2,3,4))
println(tenTimesProduct(5,6))
println(fiveHundredTimes(6))
24
300
3000

--

--

--

On a continuing learning journey..

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

BITWISE FOR DUMMIES

Global Pandemic Drives Mobile Service Apps Demand

How to use Huawei AR Engine in Unity?

Growing a feature team using lanes

Part 3 Bringing Real-Time Applications to Production

Getting Started with Styled-Components

images/img-before-babel.png

Killing GOD Objects In Flutter

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Learn

Learn

On a continuing learning journey..

More from Medium

Scala: flatMap and for-comprehension

Polymorphic functions in Scala

Scala Option Some None

Scala Option Some None example

Type Classes in Scala 2