Google News
logo
F# - Interview Questions
What is function composition and pipelining in F#?
In F#, functions can be composed from other functions. It is a process of composing in which a function represents the application of two composed functions. F# function pipelining allows us to call functions in the chain. Pipelining operator takes a function and an argument as operands and returns a value.
 
F# Function Composition Example :
let function1 name=   
  name + " FSharp"  
let function2 name =   
   name + " Programming"  
  
let programmingName = function1 >> function2  
let result = programmingName "Hello"  
printf "%s" result  
 
F# Function Pipelining Example :
let function1 name=   
  name + " FSharp"  
let function2 name =   
   name + " Programming"  
  
let result = "Hello" |> function1 |> function2  
printf "%s" result  
Advertisement