Reader small image

You're reading from  Learning Scala Programming

Product typeBook
Published inJan 2018
Reading LevelBeginner
PublisherPackt
ISBN-139781788392822
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Vikash Sharma
Vikash Sharma
author image
Vikash Sharma

Vikash Sharma is a software developer and open source technology evangelist. He tries to keep things simple, which helps him write clean and manageable code. He has invested a large amount of time learning and implementing Scala code, and he has authored video courses for Scala. He works as a developer at SAP Labs.
Read more about Vikash Sharma

Right arrow

Partially applied functions


Partially applied functions, as the name suggests, apply the functions partially. It means that for functions with multiple parameters in a parameter list, we don't provide a value for each of the parameters. If we don't want to provide parameters we just leave them blank. Now that we know this, let's look at a similar example to the one we looked at when learning currying. With this, you'll be able to differentiate between the two.

First, take a look at the multiple parameter functions, which we'll convert to partially applied forms:

def makeWebsite(platform: WebsitePlatform, domainName: DomainName, host: Host) = 
  println(s"Making $domainName using $platform with hosting from $host ") 

Here, makeWebsite, as we have already seen, takes three parameters, platform, domainName, and host. Take a look at an application we can create with various intermediate or partially applied functions:

object PaF extends App { 
 
  type WebsitePlatform = String 
  type DomainName...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Learning Scala Programming
Published in: Jan 2018Publisher: PacktISBN-13: 9781788392822

Author (1)

author image
Vikash Sharma

Vikash Sharma is a software developer and open source technology evangelist. He tries to keep things simple, which helps him write clean and manageable code. He has invested a large amount of time learning and implementing Scala code, and he has authored video courses for Scala. He works as a developer at SAP Labs.
Read more about Vikash Sharma