Practice question from FSharp Programming Advanced

Complete the pattern matching for a custom type:

type Shape =
    | Rectangle of width: float * height: float
    | Circle of radius: float

let area shape =
    match shape with
    | Rectangle(width, height) -> ____ * height
    | Circle(radius) -> ____ * radius * radius

Answer

["width","Math.PI"]

Explanation

The first blank should be width for rectangle area calculation, and the second blank should be Math.PI for circle area calculation.

More questions from Quick: FSharp Programming Advanced