RosettaCodeData/Task/Detect-division-by-zero/F-Sharp/detect-division-by-zero.fs

10 lines
251 B
Forth
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
let detectDivideZero (x : int) (y : int):int option =
try
Some(x / y)
with
| :? System.ArithmeticException -> None
printfn "12 divided by 3 is %A" (detectDivideZero 12 3)
printfn "1 divided by 0 is %A" (detectDivideZero 1 0)