Total WebSite Views Count

Scala Example: Function Composition

In scala, functions can be composed from other functions. It is a process of composing in which a function represents the application of two composed functions.

Let's see an example.
  1. object MainObject {  
  2.    def main(args: Array[String]) = {  
  3.      var result = multiplyBy2(add2(10))      // Function composition  
  4.      println(result)  
  5.     }  
  6.     def add2(a:Int):Int = {  
  7.         a+2  
  8.     }  
  9.       
  10.     def multiplyBy2(a:Int):Int = {  
  11.         a*2  
  12.     }  
  13. }  

AWS Services

AWS Services

Technology Selection & Evaluation Criteria

Technology Selection & Evaluation Criteria

Scale Cube - Scale In X Y Z Cube

Scale Cube - Scale In X Y Z Cube

Feature Post

AWS Services

About Me

About Me

Spring Cloud

Spring Cloud
Spring Cloud

Spring Cloud +mCloud Native + Big Data Archittect

Spring Cloud +mCloud Native + Big Data Archittect

ACID Transaction

ACID Transaction

Data Pipe Line Stack

Data Pipe Line Stack

Popular Posts