First-class functions and functional composition
// Simple function
let add x y = x + y
// Type signature: int -> int -> int
let result = add 3 5 // result = 8
let square x = x * x
let addOne x = x + 1
5 |> square |> addOne // 26
let squareThenAddOne =
square >> addOne
squareThenAddOne 5 // 26
// Function taking another function
let applyTwice f x = f (f x)
applyTwice square 3 // 81 (3 → 9 → 81)