Downloaded 14 times




![Par$al
Func$ons
val safeDiv: PartialFunction[(Int,Int),Int] = {
case (a,b) if b != 0 => a/b
}
scala> safeDiv(1,0)
scala.MatchError: (1,0)
scala> safeDiv.isDefinedAt (1,0)
false](https://image.slidesharecdn.com/partial-functions-scala-boldradius-150818182111-lva1-app6892/75/Partial-Functions-in-Scala-5-2048.jpg)




The document discusses total and partial functions in Scala, highlighting that total functions are defined for all input values, while partial functions are defined for only some values. It provides examples of total functions, such as a multiplication function, and partial functions, including a safe division function that raises an error for division by zero. The document also touches on combining partial functions and discusses how they relate to collections like maps and lists.