Practice question from FSharp Programming Advanced

What does this active pattern do? A. Creates a type conversion B. Defines a partial active pattern C. Creates a discriminated union D. Defines a complete active pattern E. Creates a pattern matching function

let (|Positive|Negative|Zero|) n =
    if n > 0 then Positive
    elif n < 0 then Negative
    else Zero

Answer

D

Explanation

This is a complete active pattern that categorizes numbers into Positive, Negative, or Zero cases.

More questions from Quick: FSharp Programming Advanced