F# - Passing functions as a parameter to another function

Post date: Dec 30, 2011 9:46:07 AM

GetNum is a function that takes an interger as parameter.

DoTen and DoZero are functions that takes: "a function that takes an integer parameter ( int -> a' ) and returns a unit" as its parameter.

let GetNum x = try let res = 100 / x res with | :? System.DivideByZeroException -> -1 | :? System.OverflowException -> -2 let DoTen f = f 10 let DoZero f = f 0 printfn "%A" (DoTen GetNum) printfn "%A" (DoZero GetNum)