Application Function

Function application function is represented by the term λf.λx.f x. It accepts a function as an argument and applies it to the argument of the function it returns.

// λf.λx.f x
let apply f x =
    f x

let addOne c =
    c + 1

let applyAddOne =
    addOne
    |> apply
    |> (fun a -> a 1) // 2

The function can be applied twice λf.λx.f (f x) , three times λf.λx.f (f (f x)), etc.

// λf.λx.f (f x)
let twice func arg =
    func (func arg)

// λf.λx.f (f (f x))
let thrice func arg =
    func (func (func arg))

let addOne c =
    c + 1

let applyTwice =
    addOne
    |> twice
    |> (fun a -> a 1) // 3
    
let applyThrice =
    addOne
    |> thrice
    |> (fun a -> a 1) // 4