(* F# Tutorial Exercises Addendum. Given the definition of Numbers: *) type Number = | Integer of int | Rational of int*int | Real of float | Complex of float*float;; // a. Define a function inverse that returns the inverse of the number as // Some(inverse) if the inverse exists, or None if there's no inverse. // Integer(0) and Rational(0,1), for example, have no inverse as the // denominator cannot be zero. A Rational(a,b) has inverse Rational(b,a) // if a is not zero. A Real(r) has inverse Real(1.0/r) if r is not // 0.0. A complex number a+bi has an inverse if not both a and b are // zeros, in which case the inverse is // let d = a*a+b*b in Some(Complex(a/d, b/d)); // I'll get you started: let inverse num = match num with | Integer(x) when (x<>0) -> Some(Rational(1,x)) ... _ -> None // default case // b. Assuming you've written the multiply function from the previous exercise, // write a function divide that divides a by b by multiplying a with the // inverse of b, if it exists. This function should also return an // Option, because the inverse may not exist (no divide by zero). // Hint: try to write this function using Option.map. If you can't do // that, you can resort to pattern matching.